true { RET_TOK( TRUETOK); }
false { RET_TOK( FALSETOK); }
declare { RET_TOK( DECLARE); }
-define { RET_TOK( DEFINE); }
global { RET_TOK( GLOBAL); }
constant { RET_TOK( CONSTANT); }
internal { RET_TOK( INTERNAL); }
void { RET_TY(VOID,VoidTy,"void",false); }
bool { RET_TY(BOOL,BoolTy,"bool",false); }
-sbyte { RET_TY(SBYTE,SByteTy,"sbyte",true); }
-ubyte { RET_TY(UBYTE,UByteTy,"ubyte",false); }
-short { RET_TY(SHORT,ShortTy,"short",true); }
-ushort { RET_TY(USHORT,UShortTy,"ushort",false); }
-int { RET_TY(INT,IntTy,"int",true); }
-uint { RET_TY(UINT,UIntTy,"uint",false); }
-long { RET_TY(LONG,LongTy,"long",true); }
-ulong { RET_TY(ULONG,ULongTy,"ulong",false); }
+sbyte { RET_TY(SBYTE,SByteTy,"i8",true); }
+ubyte { RET_TY(UBYTE,UByteTy,"i8",false); }
+short { RET_TY(SHORT,ShortTy,"i16",true); }
+ushort { RET_TY(USHORT,UShortTy,"i16",false); }
+int { RET_TY(INT,IntTy,"i32",true); }
+uint { RET_TY(UINT,UIntTy,"i32",false); }
+long { RET_TY(LONG,LongTy,"i64",true); }
+ulong { RET_TY(ULONG,ULongTy,"i64",false); }
+i8 { RET_TY(UBYTE,UByteTy,"i8",false); }
+i16 { RET_TY(USHORT,UShortTy,"i16",false); }
+i32 { RET_TY(UINT,UIntTy,"i32",false); }
+i64 { RET_TY(ULONG,ULongTy,"i64",false); }
float { RET_TY(FLOAT,FloatTy,"float",false); }
double { RET_TY(DOUBLE,DoubleTy,"double",false); }
label { RET_TY(LABEL,LabelTy,"label",false); }
unsigned SizeOfPointer = 32;
static uint64_t unique = 1;
+// This bool controls whether attributes are ever added to function declarations
+// definitions and calls.
+static bool AddAttributes = false;
+
typedef std::vector<TypeInfo> TypeVector;
static TypeVector EnumeratedTypes;
typedef std::map<std::string,TypeInfo> TypeMap;
}
void UpgradeAssembly(const std::string &infile, std::istream& in,
- std::ostream &out, bool debug)
+ std::ostream &out, bool debug, bool addAttrs)
{
Upgradelineno = 1;
CurFilename = infile;
LexInput = ∈
yydebug = debug;
+ AddAttributes = addAttrs;
O = &out;
if (yyparse()) {
// fp -> ptr cast is no longer supported but we must upgrade this
// by doing a double cast: fp -> int -> ptr
if (isConst)
- Source = "ulong fptoui(" + Source + " to ulong)";
+ Source = "i64 fptoui(" + Source + " to i64)";
else {
*O << " %cast_upgrade" << unique << " = fptoui " << Source
- << " to ulong\n";
- Source = "ulong %cast_upgrade" + llvm::utostr(unique);
+ << " to i64\n";
+ Source = "i64 %cast_upgrade" + llvm::utostr(unique);
}
// Update the SrcTy for the getCastOpcode call below
SrcTy.destroy();
- SrcTy.newTy = new std::string("ulong");
+ SrcTy.newTy = new std::string("i64");
SrcTy.oldTy = ULongTy;
} else if (DstTy.oldTy == BoolTy && SrcTy.oldTy != BoolTy) {
// cast ptr %x to bool was previously defined as setne ptr %x, null
%token <String> NULL_TOK UNDEF ZEROINITIALIZER TRUETOK FALSETOK
%token <String> TYPE VAR_ID LABELSTR STRINGCONSTANT
%token <String> IMPLEMENTATION BEGINTOK ENDTOK
-%token <String> DECLARE DEFINE GLOBAL CONSTANT SECTION VOLATILE
+%token <String> DECLARE GLOBAL CONSTANT SECTION VOLATILE
%token <String> TO DOTDOTDOT CONST INTERNAL LINKONCE WEAK
%token <String> DLLIMPORT DLLEXPORT EXTERN_WEAK APPENDING
%token <String> NOT EXTERNAL TARGET TRIPLE ENDIAN POINTERSIZE LITTLE BIG
}
| /* empty */ { $$ = new std::string(); };
-FunctionHeaderH : OptCallingConv TypesV Name '(' ArgList ')'
- OptSection OptAlign {
+FunctionHeaderH
+ : OptCallingConv TypesV Name '(' ArgList ')' OptSection OptAlign {
if (!$1->empty()) {
*$1 += " ";
}
delete $1; delete $2; delete $3;
$$ = 0;
}
- | DEFINE OptLinkage FunctionHeaderH BEGIN {
- *O << *$1 << ' ';
- if (!$2->empty()) {
- *O << *$2 << ' ';
- }
- *O << *$3 << ' ' << *$4 << '\n';
- delete $1; delete $2; delete $3; delete $4;
- $$ = 0;
- }
;
END : ENDTOK { $$ = new std::string("}"); delete $1; }
Function : FunctionHeader BasicBlockList END {
if ($2)
*O << *$2;
- *O << '\n' << *$3 << '\n';
+ *O << *$3 << "\n\n";
$$ = 0;
};
VI.type.getBitWidth() < 64) {
std::string* old = VI.val;
*O << " %gep_upgrade" << unique << " = zext " << *old
- << " to ulong\n";
- VI.val = new std::string("ulong %gep_upgrade" + llvm::utostr(unique++));
+ << " to i64\n";
+ VI.val = new std::string("i64 %gep_upgrade" + llvm::utostr(unique++));
VI.type.oldTy = ULongTy;
delete old;
}
errMsg += "end-of-file.";
else
errMsg += "token: '" + std::string(Upgradetext, Upgradeleng) + "'";
- std::cerr << errMsg << '\n';
+ std::cerr << "llvm-upgrade: " << errMsg << '\n';
exit(1);
}