Allow information about the target to be specified in the .ll file

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5843 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2003-04-22 19:07:06 +00:00
parent 0bc0f47845
commit b9bcbb533f
2 changed files with 28 additions and 1 deletions

View File

@ -19,6 +19,7 @@
%{
#include "ParserInternals.h"
#include "llvm/Module.h"
#include <list>
#include "llvmAsmParser.h"
#include <ctype.h>
@ -176,6 +177,11 @@ null { return NULL_TOK; }
to { return TO; }
except { return EXCEPT; }
not { return NOT; } /* Deprecated, turned into XOR */
target { return TARGET; }
endian { return ENDIAN; }
pointersize { return POINTERSIZE; }
little { return LITTLE; }
big { return BIG; }
void { llvmAsmlval.PrimType = Type::VoidTy ; return VOID; }
bool { llvmAsmlval.PrimType = Type::BoolTy ; return BOOL; }

View File

@ -635,6 +635,7 @@ Module *RunVMAsmParser(const std::string &Filename, FILE *F) {
Instruction::TermOps TermOpVal;
Instruction::MemoryOps MemOpVal;
Instruction::OtherOps OtherOpVal;
Module::Endianness Endianness;
}
%type <ModuleVal> Module FunctionList
@ -653,6 +654,7 @@ Module *RunVMAsmParser(const std::string &Filename, FILE *F) {
%type <JumpTable> JumpTable
%type <BoolVal> GlobalType // GLOBAL or CONSTANT?
%type <Linkage> OptLinkage
%type <Endianness> BigOrLittle
// ValueRef - Unresolved reference to a definition or BB
%type <ValIDVal> ValueRef ConstValueRef SymbolicValueRef
@ -683,7 +685,7 @@ Module *RunVMAsmParser(const std::string &Filename, FILE *F) {
%token IMPLEMENTATION TRUE FALSE BEGINTOK ENDTOK DECLARE GLOBAL CONSTANT
%token TO EXCEPT DOTDOTDOT NULL_TOK CONST INTERNAL LINKONCE APPENDING
%token OPAQUE NOT EXTERNAL
%token OPAQUE NOT EXTERNAL TARGET ENDIAN POINTERSIZE LITTLE BIG
// Basic Block Terminating Operators
%token <TermOpVal> RET BR SWITCH
@ -1177,10 +1179,29 @@ ConstPool : ConstPool OptAssign CONST ConstVal {
}
delete $5;
}
| ConstPool TARGET TargetDefinition {
}
| /* empty: end of list */ {
};
BigOrLittle : BIG { $$ = Module::BigEndian; };
BigOrLittle : LITTLE { $$ = Module::LittleEndian; };
TargetDefinition : ENDIAN '=' BigOrLittle {
CurModule.CurrentModule->setEndianness($3);
}
| POINTERSIZE '=' EUINT64VAL {
if ($3 == 32)
CurModule.CurrentModule->setPointerSize(Module::Pointer32);
else if ($3 == 64)
CurModule.CurrentModule->setPointerSize(Module::Pointer64);
else
ThrowException("Invalid pointer size: '" + utostr($3) + "'!");
};
//===----------------------------------------------------------------------===//
// Rules to match Function Headers
//===----------------------------------------------------------------------===//