From 7f70559bc47877bafc6dfa92b7df6b64650445fb Mon Sep 17 00:00:00 2001
From: Anton Korobeynikov
Note that we plan to eventually expand the target description capabilities @@ -1082,7 +1081,11 @@ and can includes more information:
When the number of operands to the constant is one, we have an 'undef' value @@ -1345,7 +1348,7 @@ of the specified type.
Inline Assembler entries are stored in the constant pool, though they are not @@ -1369,7 +1372,7 @@ of the specified type.
Type | +Field Description | +
---|---|
bit(0-15) | +The linkage type of the function: 0=External, 1=Weak, +2=Appending, 3=Internal, 4=LinkOnce, 5=DllImport, 6=DllExport1 | +
bit(16-31) | +Visibility style: 0=Default, 1=Hidden. | +
The next two types of linkage are targeted for Microsoft Windows platform only. They are designed to support importing (exporting) symbols from (to) DLLs.
+For example, since the ".LC0"
+ For example, since the ".LC0"
variable is defined to be internal, if another module defined a ".LC0"
variable and was linked with this one, one of the two would be renamed,
preventing a collision. Since "main" and "puts" are
@@ -497,7 +500,7 @@ external (i.e., lacking any linkage declarations), they are accessible
outside of the current module. It is illegal for a function declaration
to have any linkage type other than "externally visible", dllimport,
-or extern_weak.
Parameter attributes consist of an at sign (@) followed by either a single keyword or a comma separate list of keywords enclosed in parentheses. For - example:
+ example:%someFunc = i16 @zext (i8 @(sext) %someParam) %someFunc = i16 @zext (i8 @zext %someParam)- Note that the two function types above are unique because the parameter - has a different attribute (@sext in the first one, @zext in the second). +Note that the two function types above are unique because the parameter has + a different attribute (@sext in the first one, @zext in the second).
-Currently, only the following parameter attributes are defined: +
Currently, only the following parameter attributes are defined:
The current motivation for parameter attributes is to enable the sign and zero extend information necessary for the C calling convention to be passed @@ -3053,7 +3056,7 @@ a pointer type, ty2.
The 'inttoptr' instruction takes an integer value to cast, and a type to cast it to, which must be a -pointer type. +pointer type.
The 'inttoptr' instruction converts value to type @@ -3172,7 +3175,6 @@ yields a i1 result, as follows: true if var1 is less than var2.
If the operands are pointer typed, the pointer values are treated as integers and then compared.
diff --git a/include/llvm/Bytecode/BytecodeHandler.h b/include/llvm/Bytecode/BytecodeHandler.h index c693380..1d95db5 100644 --- a/include/llvm/Bytecode/BytecodeHandler.h +++ b/include/llvm/Bytecode/BytecodeHandler.h @@ -112,6 +112,7 @@ public: const Type* ElemType, ///< The type of the global variable bool isConstant, ///< Whether the GV is constant or not GlobalValue::LinkageTypes,///< The linkage type of the GV + GlobalValue::VisibilityTypes,///< The visibility style of the GV unsigned SlotNum, ///< Slot number of GV unsigned initSlot ///< Slot number of GV's initializer (0 if none) ) {} diff --git a/include/llvm/GlobalValue.h b/include/llvm/GlobalValue.h index c3b96f2..2fbbbc0 100644 --- a/include/llvm/GlobalValue.h +++ b/include/llvm/GlobalValue.h @@ -38,14 +38,19 @@ public: ExternalWeakLinkage, /// ExternalWeak linkage description GhostLinkage /// Stand-in functions for streaming fns from BC files }; + enum VisibilityTypes { + DefaultVisibility, + HiddenVisibility + }; protected: GlobalValue(const Type *Ty, ValueTy vty, Use *Ops, unsigned NumOps, LinkageTypes linkage, const std::string &name = "") - : Constant(Ty, vty, Ops, NumOps, name), - Parent(0), Linkage(linkage), Alignment(0) { } + : Constant(Ty, vty, Ops, NumOps, name), Parent(0), + Linkage(linkage), Visibility(DefaultVisibility), Alignment(0) { } Module *Parent; LinkageTypes Linkage; // The linkage of this global + VisibilityTypes Visibility; // The visibility style of this global unsigned Alignment; // Alignment of this symbol, must be power of two std::string Section; // Section to emit this into, empty mean default public: @@ -58,6 +63,10 @@ public: assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!"); Alignment = Align; } + + VisibilityTypes getVisibility() const { return Visibility; } + bool hasHiddenVisibility() const { return Visibility == HiddenVisibility; } + void setVisibility(VisibilityTypes V) { Visibility = V; } bool hasSection() const { return !Section.empty(); } const std::string &getSection() const { return Section; } diff --git a/lib/AsmParser/Lexer.l b/lib/AsmParser/Lexer.l index 5300b3d..22fe64b 100644 --- a/lib/AsmParser/Lexer.l +++ b/lib/AsmParser/Lexer.l @@ -203,6 +203,7 @@ weak { return WEAK; } appending { return APPENDING; } dllimport { return DLLIMPORT; } dllexport { return DLLEXPORT; } +hidden { return HIDDEN; } extern_weak { return EXTERN_WEAK; } external { return EXTERNAL; } implementation { return IMPLEMENTATION; } diff --git a/lib/AsmParser/Lexer.l.cvs b/lib/AsmParser/Lexer.l.cvs index 5300b3d..22fe64b 100644 --- a/lib/AsmParser/Lexer.l.cvs +++ b/lib/AsmParser/Lexer.l.cvs @@ -203,6 +203,7 @@ weak { return WEAK; } appending { return APPENDING; } dllimport { return DLLIMPORT; } dllexport { return DLLEXPORT; } +hidden { return HIDDEN; } extern_weak { return EXTERN_WEAK; } external { return EXTERNAL; } implementation { return IMPLEMENTATION; } diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y index b84cf25..52d8847 100644 --- a/lib/AsmParser/llvmAsmParser.y +++ b/lib/AsmParser/llvmAsmParser.y @@ -210,6 +210,7 @@ static struct PerFunctionInfo { std::map