llir-opt
0.0.1
Low-Level Post-Link Optimiser for OCaml and C
|
8 #include <llvm/ADT/ilist_node.h>
10 #include "core/global.h"
11 #include "core/symbol_table.h"
20 class Extern final :
public llvm::ilist_node_with_parent<Extern, Prog>,
public Global {
30 const std::string_view name,
31 Visibility visibility = Visibility::GLOBAL_DEFAULT
38 const std::string_view name,
39 const std::string_view section,
40 Visibility visibility = Visibility::GLOBAL_DEFAULT
76 void SetSection(
const std::string_view section) { section_ = section; }
78 std::optional<const std::string_view>
GetSection()
const {
return section_; }
81 void dump(llvm::raw_ostream &os = llvm::errs())
const override;
86 void setParent(
Prog *parent) { parent_ = parent; }
92 std::optional<std::string> section_;
Ref< Value > GetValue()
Returns the alias, if it exists.
Definition: extern.h:65
void removeFromParent() override
Removes an extern from the parent.
Definition: extern.cpp:39
Kind
Enumeration of global kinds.
Definition: global.h:30
Definition: symbol_table.h:33
void eraseFromParent() override
Erases the extern from the parent, deleting it.
Definition: extern.cpp:45
std::optional< llvm::Align > GetAlignment() const override
Externs have no known alignment.
Definition: extern.h:57
static constexpr Global::Kind kGlobalKind
Kind of the global.
Definition: extern.h:23
Prog * getParent()
Returns the parent node.
Definition: extern.h:49
~Extern() override
Definition: extern.cpp:34
ConstRef< Value > GetValue() const
Returns the alias, if it exists.
Definition: extern.h:67
void SetValue(Ref< Value > g)
Maps the extern to an alias.
Definition: extern.cpp:51
Extern(const std::string_view name, Visibility visibility=Visibility::GLOBAL_DEFAULT)
Definition: extern.cpp:14
Prog * getProg() override
Returns the program to which the extern belongs.
Definition: extern.h:73
std::optional< const std::string_view > GetSection() const
Returns the section.
Definition: extern.h:78
bool HasValue() const
Checks if the extern is a weak alias to another symbol.
Definition: extern.h:70
void dump(llvm::raw_ostream &os=llvm::errs()) const override
Dumps the representation of the function.
Definition: extern.cpp:57
void SetSection(const std::string_view section)
Sets the section of the extern.
Definition: extern.h:76