mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-17 21:29:20 +00:00
For PR950:
Don't attempt to parse both the old and new grammars. It is near impossible to get it right. Remove support for the new define keyword and don't attempt to insert parameter attributes because there isn't enough contextual information for it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32784 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
88cfda2122
commit
05e52a1b35
@ -105,7 +105,6 @@ end { RET_TOK( ENDTOK); }
|
||||
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); }
|
||||
@ -149,14 +148,18 @@ x86_fastcallcc { RET_TOK( X86_FASTCALLCC_TOK); }
|
||||
|
||||
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); }
|
||||
|
@ -34,6 +34,10 @@ std::istream* LexInput = 0;
|
||||
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;
|
||||
@ -50,12 +54,13 @@ void destroy(ValueList* VL) {
|
||||
}
|
||||
|
||||
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()) {
|
||||
@ -176,15 +181,15 @@ static std::string getCastUpgrade(
|
||||
// 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
|
||||
@ -286,7 +291,7 @@ getCompareOp(const std::string& setcc, const TypeInfo& TI) {
|
||||
%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
|
||||
@ -922,8 +927,8 @@ ArgList : ArgListH {
|
||||
}
|
||||
| /* empty */ { $$ = new std::string(); };
|
||||
|
||||
FunctionHeaderH : OptCallingConv TypesV Name '(' ArgList ')'
|
||||
OptSection OptAlign {
|
||||
FunctionHeaderH
|
||||
: OptCallingConv TypesV Name '(' ArgList ')' OptSection OptAlign {
|
||||
if (!$1->empty()) {
|
||||
*$1 += " ";
|
||||
}
|
||||
@ -955,15 +960,6 @@ FunctionHeader
|
||||
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; }
|
||||
@ -972,7 +968,7 @@ END : ENDTOK { $$ = new std::string("}"); delete $1; }
|
||||
Function : FunctionHeader BasicBlockList END {
|
||||
if ($2)
|
||||
*O << *$2;
|
||||
*O << '\n' << *$3 << '\n';
|
||||
*O << *$3 << "\n\n";
|
||||
$$ = 0;
|
||||
};
|
||||
|
||||
@ -1373,8 +1369,8 @@ MemoryInst : MALLOC Types OptCAlign {
|
||||
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;
|
||||
}
|
||||
@ -1400,6 +1396,6 @@ int yyerror(const char *ErrorMsg) {
|
||||
errMsg += "end-of-file.";
|
||||
else
|
||||
errMsg += "token: '" + std::string(Upgradetext, Upgradeleng) + "'";
|
||||
std::cerr << errMsg << '\n';
|
||||
std::cerr << "llvm-upgrade: " << errMsg << '\n';
|
||||
exit(1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user