Allow information about the target to be specified in the .ll file
authorChris Lattner <sabre@nondot.org>
Tue, 22 Apr 2003 19:07:06 +0000 (19:07 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 22 Apr 2003 19:07:06 +0000 (19:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5843 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AsmParser/Lexer.l
lib/AsmParser/llvmAsmParser.y

index 47c067ba8ce7e2736c03ac3b47464226362e1b30..92d4f3424f87b938b0912f2b12e7d2463b66364e 100644 (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;   }
index 8309c91d5edcc3c66ff85542635b59687bc25695..19cda682a16d1bf2fdf8f3e8d883bec54632d4b0 100644 (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
 //===----------------------------------------------------------------------===//