[llvm-commits] CVS: llvm/lib/AsmParser/Lexer.l Lexer.l.cvs llvmAsmParser.y llvmAsmParser.y.cvs
Anton Korobeynikov
asl at math.spbu.ru
Thu Sep 14 11:24:04 PDT 2006
Changes in directory llvm/lib/AsmParser:
Lexer.l updated: 1.75 -> 1.76
Lexer.l.cvs updated: 1.5 -> 1.6
llvmAsmParser.y updated: 1.258 -> 1.259
llvmAsmParser.y.cvs updated: 1.10 -> 1.11
---
Log message:
Adding dllimport, dllexport and external weak linkage types.
DLL* linkages got full (I hope) codegeneration support in C & both x86
assembler backends.
External weak linkage added for future use, we don't provide any
codegeneration, etc. support for it.
---
Diffs of the changes: (+106 -30)
Lexer.l | 3 ++
Lexer.l.cvs | 3 ++
llvmAsmParser.y | 65 ++++++++++++++++++++++++++++++++++++++++------------
llvmAsmParser.y.cvs | 65 ++++++++++++++++++++++++++++++++++++++++------------
4 files changed, 106 insertions(+), 30 deletions(-)
Index: llvm/lib/AsmParser/Lexer.l
diff -u llvm/lib/AsmParser/Lexer.l:1.75 llvm/lib/AsmParser/Lexer.l:1.76
--- llvm/lib/AsmParser/Lexer.l:1.75 Fri Aug 18 03:43:06 2006
+++ llvm/lib/AsmParser/Lexer.l Thu Sep 14 13:23:26 2006
@@ -191,6 +191,9 @@
linkonce { return LINKONCE; }
weak { return WEAK; }
appending { return APPENDING; }
+dllimport { return DLLIMPORT; }
+dllexport { return DLLEXPORT; }
+extern_weak { return EXTERN_WEAK; }
uninitialized { return EXTERNAL; } /* Deprecated, turn into external */
external { return EXTERNAL; }
implementation { return IMPLEMENTATION; }
Index: llvm/lib/AsmParser/Lexer.l.cvs
diff -u llvm/lib/AsmParser/Lexer.l.cvs:1.5 llvm/lib/AsmParser/Lexer.l.cvs:1.6
--- llvm/lib/AsmParser/Lexer.l.cvs:1.5 Fri Aug 18 03:43:06 2006
+++ llvm/lib/AsmParser/Lexer.l.cvs Thu Sep 14 13:23:26 2006
@@ -191,6 +191,9 @@
linkonce { return LINKONCE; }
weak { return WEAK; }
appending { return APPENDING; }
+dllimport { return DLLIMPORT; }
+dllexport { return DLLEXPORT; }
+extern_weak { return EXTERN_WEAK; }
uninitialized { return EXTERNAL; } /* Deprecated, turn into external */
external { return EXTERNAL; }
implementation { return IMPLEMENTATION; }
Index: llvm/lib/AsmParser/llvmAsmParser.y
diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.258 llvm/lib/AsmParser/llvmAsmParser.y:1.259
--- llvm/lib/AsmParser/llvmAsmParser.y:1.258 Fri Aug 18 12:34:24 2006
+++ llvm/lib/AsmParser/llvmAsmParser.y Thu Sep 14 13:23:26 2006
@@ -150,9 +150,10 @@
static struct PerFunctionInfo {
Function *CurrentFunction; // Pointer to current function being created
- std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
+ std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
std::map<const Type*, ValueList> LateResolveValues;
- bool isDeclare; // Is this function a forward declararation?
+ bool isDeclare; // Is this function a forward declararation?
+ GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
/// BBForwardRefs - When we see forward references to basic blocks, keep
/// track of them here.
@@ -163,6 +164,7 @@
inline PerFunctionInfo() {
CurrentFunction = 0;
isDeclare = false;
+ Linkage = GlobalValue::ExternalLinkage;
}
inline void FunctionStart(Function *M) {
@@ -184,6 +186,7 @@
Values.clear(); // Clear out function local definitions
CurrentFunction = 0;
isDeclare = false;
+ Linkage = GlobalValue::ExternalLinkage;
}
} CurFun; // Info for the current function...
@@ -998,7 +1001,8 @@
%token IMPLEMENTATION ZEROINITIALIZER TRUETOK FALSETOK BEGINTOK ENDTOK
%token DECLARE GLOBAL CONSTANT SECTION VOLATILE
-%token TO DOTDOTDOT NULL_TOK UNDEF CONST INTERNAL LINKONCE WEAK APPENDING
+%token TO DOTDOTDOT NULL_TOK UNDEF CONST INTERNAL LINKONCE WEAK APPENDING
+%token DLLIMPORT DLLEXPORT EXTERN_WEAK
%token OPAQUE NOT EXTERNAL TARGET TRIPLE ENDIAN POINTERSIZE LITTLE BIG ALIGN
%token DEPLIBS CALL TAIL ASM_TOK MODULE SIDEEFFECT
%token CC_TOK CCC_TOK CSRETCC_TOK FASTCC_TOK COLDCC_TOK
@@ -1070,11 +1074,14 @@
CHECK_FOR_ERROR
};
-OptLinkage : INTERNAL { $$ = GlobalValue::InternalLinkage; } |
- LINKONCE { $$ = GlobalValue::LinkOnceLinkage; } |
- WEAK { $$ = GlobalValue::WeakLinkage; } |
- APPENDING { $$ = GlobalValue::AppendingLinkage; } |
- /*empty*/ { $$ = GlobalValue::ExternalLinkage; };
+OptLinkage : INTERNAL { $$ = GlobalValue::InternalLinkage; } |
+ LINKONCE { $$ = GlobalValue::LinkOnceLinkage; } |
+ WEAK { $$ = GlobalValue::WeakLinkage; } |
+ APPENDING { $$ = GlobalValue::AppendingLinkage; } |
+ DLLIMPORT { $$ = GlobalValue::DLLImportLinkage; } |
+ DLLEXPORT { $$ = GlobalValue::DLLExportLinkage; } |
+ EXTERN_WEAK { $$ = GlobalValue::ExternalWeakLinkage; } |
+ /*empty*/ { $$ = GlobalValue::ExternalLinkage; };
OptCallingConv : /*empty*/ { $$ = CallingConv::C; } |
CCC_TOK { $$ = CallingConv::C; } |
@@ -1728,8 +1735,24 @@
CHECK_FOR_ERROR
}
| ConstPool OptAssign EXTERNAL GlobalType Types {
- CurGV = ParseGlobalVariable($2, GlobalValue::ExternalLinkage,
- $4, *$5, 0);
+ CurGV = ParseGlobalVariable($2,
+ GlobalValue::ExternalLinkage, $4, *$5, 0);
+ delete $5;
+ } GlobalVarAttributes {
+ CurGV = 0;
+ CHECK_FOR_ERROR
+ }
+ | ConstPool OptAssign DLLIMPORT GlobalType Types {
+ CurGV = ParseGlobalVariable($2,
+ GlobalValue::DLLImportLinkage, $4, *$5, 0);
+ delete $5;
+ } GlobalVarAttributes {
+ CurGV = 0;
+ CHECK_FOR_ERROR
+ }
+ | ConstPool OptAssign EXTERN_WEAK GlobalType Types {
+ CurGV = ParseGlobalVariable($2,
+ GlobalValue::ExternalWeakLinkage, $4, *$5, 0);
delete $5;
} GlobalVarAttributes {
CurGV = 0;
@@ -1895,9 +1918,17 @@
AI != AE; ++AI)
AI->setName("");
+ if (CurFun.isDeclare) {
+ Fn->setLinkage(CurFun.Linkage);
+ }
} else { // Not already defined?
Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
CurModule.CurrentModule);
+
+ if (CurFun.isDeclare) {
+ Fn->setLinkage(CurFun.Linkage);
+ }
+
InsertValue(Fn, CurModule.Values);
}
@@ -1948,11 +1979,15 @@
CHECK_FOR_ERROR
};
-FunctionProto : DECLARE { CurFun.isDeclare = true; } FunctionHeaderH {
- $$ = CurFun.CurrentFunction;
- CurFun.FunctionDone();
- CHECK_FOR_ERROR
-};
+FnDeclareLinkage: /*default*/ |
+ DLLIMPORT { CurFun.Linkage = GlobalValue::DLLImportLinkage } |
+ EXTERN_WEAK { CurFun.Linkage = GlobalValue::DLLImportLinkage };
+
+FunctionProto : DECLARE { CurFun.isDeclare = true; } FnDeclareLinkage FunctionHeaderH {
+ $$ = CurFun.CurrentFunction;
+ CurFun.FunctionDone();
+ CHECK_FOR_ERROR
+ };
//===----------------------------------------------------------------------===//
// Rules to match Basic Blocks
Index: llvm/lib/AsmParser/llvmAsmParser.y.cvs
diff -u llvm/lib/AsmParser/llvmAsmParser.y.cvs:1.10 llvm/lib/AsmParser/llvmAsmParser.y.cvs:1.11
--- llvm/lib/AsmParser/llvmAsmParser.y.cvs:1.10 Fri Aug 18 12:34:45 2006
+++ llvm/lib/AsmParser/llvmAsmParser.y.cvs Thu Sep 14 13:23:26 2006
@@ -150,9 +150,10 @@
static struct PerFunctionInfo {
Function *CurrentFunction; // Pointer to current function being created
- std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
+ std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
std::map<const Type*, ValueList> LateResolveValues;
- bool isDeclare; // Is this function a forward declararation?
+ bool isDeclare; // Is this function a forward declararation?
+ GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
/// BBForwardRefs - When we see forward references to basic blocks, keep
/// track of them here.
@@ -163,6 +164,7 @@
inline PerFunctionInfo() {
CurrentFunction = 0;
isDeclare = false;
+ Linkage = GlobalValue::ExternalLinkage;
}
inline void FunctionStart(Function *M) {
@@ -184,6 +186,7 @@
Values.clear(); // Clear out function local definitions
CurrentFunction = 0;
isDeclare = false;
+ Linkage = GlobalValue::ExternalLinkage;
}
} CurFun; // Info for the current function...
@@ -998,7 +1001,8 @@
%token IMPLEMENTATION ZEROINITIALIZER TRUETOK FALSETOK BEGINTOK ENDTOK
%token DECLARE GLOBAL CONSTANT SECTION VOLATILE
-%token TO DOTDOTDOT NULL_TOK UNDEF CONST INTERNAL LINKONCE WEAK APPENDING
+%token TO DOTDOTDOT NULL_TOK UNDEF CONST INTERNAL LINKONCE WEAK APPENDING
+%token DLLIMPORT DLLEXPORT EXTERN_WEAK
%token OPAQUE NOT EXTERNAL TARGET TRIPLE ENDIAN POINTERSIZE LITTLE BIG ALIGN
%token DEPLIBS CALL TAIL ASM_TOK MODULE SIDEEFFECT
%token CC_TOK CCC_TOK CSRETCC_TOK FASTCC_TOK COLDCC_TOK
@@ -1070,11 +1074,14 @@
CHECK_FOR_ERROR
};
-OptLinkage : INTERNAL { $$ = GlobalValue::InternalLinkage; } |
- LINKONCE { $$ = GlobalValue::LinkOnceLinkage; } |
- WEAK { $$ = GlobalValue::WeakLinkage; } |
- APPENDING { $$ = GlobalValue::AppendingLinkage; } |
- /*empty*/ { $$ = GlobalValue::ExternalLinkage; };
+OptLinkage : INTERNAL { $$ = GlobalValue::InternalLinkage; } |
+ LINKONCE { $$ = GlobalValue::LinkOnceLinkage; } |
+ WEAK { $$ = GlobalValue::WeakLinkage; } |
+ APPENDING { $$ = GlobalValue::AppendingLinkage; } |
+ DLLIMPORT { $$ = GlobalValue::DLLImportLinkage; } |
+ DLLEXPORT { $$ = GlobalValue::DLLExportLinkage; } |
+ EXTERN_WEAK { $$ = GlobalValue::ExternalWeakLinkage; } |
+ /*empty*/ { $$ = GlobalValue::ExternalLinkage; };
OptCallingConv : /*empty*/ { $$ = CallingConv::C; } |
CCC_TOK { $$ = CallingConv::C; } |
@@ -1728,8 +1735,24 @@
CHECK_FOR_ERROR
}
| ConstPool OptAssign EXTERNAL GlobalType Types {
- CurGV = ParseGlobalVariable($2, GlobalValue::ExternalLinkage,
- $4, *$5, 0);
+ CurGV = ParseGlobalVariable($2,
+ GlobalValue::ExternalLinkage, $4, *$5, 0);
+ delete $5;
+ } GlobalVarAttributes {
+ CurGV = 0;
+ CHECK_FOR_ERROR
+ }
+ | ConstPool OptAssign DLLIMPORT GlobalType Types {
+ CurGV = ParseGlobalVariable($2,
+ GlobalValue::DLLImportLinkage, $4, *$5, 0);
+ delete $5;
+ } GlobalVarAttributes {
+ CurGV = 0;
+ CHECK_FOR_ERROR
+ }
+ | ConstPool OptAssign EXTERN_WEAK GlobalType Types {
+ CurGV = ParseGlobalVariable($2,
+ GlobalValue::ExternalWeakLinkage, $4, *$5, 0);
delete $5;
} GlobalVarAttributes {
CurGV = 0;
@@ -1895,9 +1918,17 @@
AI != AE; ++AI)
AI->setName("");
+ if (CurFun.isDeclare) {
+ Fn->setLinkage(CurFun.Linkage);
+ }
} else { // Not already defined?
Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
CurModule.CurrentModule);
+
+ if (CurFun.isDeclare) {
+ Fn->setLinkage(CurFun.Linkage);
+ }
+
InsertValue(Fn, CurModule.Values);
}
@@ -1948,11 +1979,15 @@
CHECK_FOR_ERROR
};
-FunctionProto : DECLARE { CurFun.isDeclare = true; } FunctionHeaderH {
- $$ = CurFun.CurrentFunction;
- CurFun.FunctionDone();
- CHECK_FOR_ERROR
-};
+FnDeclareLinkage: /*default*/ |
+ DLLIMPORT { CurFun.Linkage = GlobalValue::DLLImportLinkage } |
+ EXTERN_WEAK { CurFun.Linkage = GlobalValue::DLLImportLinkage };
+
+FunctionProto : DECLARE { CurFun.isDeclare = true; } FnDeclareLinkage FunctionHeaderH {
+ $$ = CurFun.CurrentFunction;
+ CurFun.FunctionDone();
+ CHECK_FOR_ERROR
+ };
//===----------------------------------------------------------------------===//
// Rules to match Basic Blocks
More information about the llvm-commits
mailing list