mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-15 20:29:48 +00:00
Parse volatile loads/stores
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8402 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
dba2b225c8
commit
15c9c0352e
@ -185,6 +185,7 @@ endian { return ENDIAN; }
|
|||||||
pointersize { return POINTERSIZE; }
|
pointersize { return POINTERSIZE; }
|
||||||
little { return LITTLE; }
|
little { return LITTLE; }
|
||||||
big { return BIG; }
|
big { return BIG; }
|
||||||
|
volatile { return VOLATILE; }
|
||||||
|
|
||||||
void { llvmAsmlval.PrimType = Type::VoidTy ; return VOID; }
|
void { llvmAsmlval.PrimType = Type::VoidTy ; return VOID; }
|
||||||
bool { llvmAsmlval.PrimType = Type::BoolTy ; return BOOL; }
|
bool { llvmAsmlval.PrimType = Type::BoolTy ; return BOOL; }
|
||||||
|
@ -664,6 +664,7 @@ Module *RunVMAsmParser(const std::string &Filename, FILE *F) {
|
|||||||
%type <TypeList> TypeListI ArgTypeListI
|
%type <TypeList> TypeListI ArgTypeListI
|
||||||
%type <JumpTable> JumpTable
|
%type <JumpTable> JumpTable
|
||||||
%type <BoolVal> GlobalType // GLOBAL or CONSTANT?
|
%type <BoolVal> GlobalType // GLOBAL or CONSTANT?
|
||||||
|
%type <BoolVal> OptVolatile // 'volatile' or not
|
||||||
%type <Linkage> OptLinkage
|
%type <Linkage> OptLinkage
|
||||||
%type <Endianness> BigOrLittle
|
%type <Endianness> BigOrLittle
|
||||||
|
|
||||||
@ -695,7 +696,7 @@ Module *RunVMAsmParser(const std::string &Filename, FILE *F) {
|
|||||||
|
|
||||||
|
|
||||||
%token IMPLEMENTATION ZEROINITIALIZER TRUE FALSE BEGINTOK ENDTOK
|
%token IMPLEMENTATION ZEROINITIALIZER TRUE FALSE BEGINTOK ENDTOK
|
||||||
%token DECLARE GLOBAL CONSTANT
|
%token DECLARE GLOBAL CONSTANT VOLATILE
|
||||||
%token TO EXCEPT DOTDOTDOT NULL_TOK CONST INTERNAL LINKONCE APPENDING
|
%token TO EXCEPT DOTDOTDOT NULL_TOK CONST INTERNAL LINKONCE APPENDING
|
||||||
%token OPAQUE NOT EXTERNAL TARGET ENDIAN POINTERSIZE LITTLE BIG
|
%token OPAQUE NOT EXTERNAL TARGET ENDIAN POINTERSIZE LITTLE BIG
|
||||||
|
|
||||||
@ -1705,10 +1706,18 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
|
|||||||
|
|
||||||
// IndexList - List of indices for GEP based instructions...
|
// IndexList - List of indices for GEP based instructions...
|
||||||
IndexList : ',' ValueRefList {
|
IndexList : ',' ValueRefList {
|
||||||
$$ = $2;
|
$$ = $2;
|
||||||
} | /* empty */ {
|
} | /* empty */ {
|
||||||
$$ = new std::vector<Value*>();
|
$$ = new std::vector<Value*>();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
OptVolatile : VOLATILE {
|
||||||
|
$$ = true;
|
||||||
|
}
|
||||||
|
| /* empty */ {
|
||||||
|
$$ = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
MemoryInst : MALLOC Types {
|
MemoryInst : MALLOC Types {
|
||||||
$$ = new MallocInst(*$2);
|
$$ = new MallocInst(*$2);
|
||||||
@ -1733,25 +1742,25 @@ MemoryInst : MALLOC Types {
|
|||||||
$$ = new FreeInst($2);
|
$$ = new FreeInst($2);
|
||||||
}
|
}
|
||||||
|
|
||||||
| LOAD Types ValueRef {
|
| OptVolatile LOAD Types ValueRef {
|
||||||
if (!isa<PointerType>($2->get()))
|
if (!isa<PointerType>($3->get()))
|
||||||
ThrowException("Can't load from nonpointer type: " +
|
ThrowException("Can't load from nonpointer type: " +
|
||||||
(*$2)->getDescription());
|
(*$3)->getDescription());
|
||||||
$$ = new LoadInst(getVal(*$2, $3));
|
$$ = new LoadInst(getVal(*$3, $4), "", $2);
|
||||||
delete $2;
|
delete $3;
|
||||||
}
|
}
|
||||||
| STORE ResolvedVal ',' Types ValueRef {
|
| OptVolatile STORE ResolvedVal ',' Types ValueRef {
|
||||||
const PointerType *PT = dyn_cast<PointerType>($4->get());
|
const PointerType *PT = dyn_cast<PointerType>($5->get());
|
||||||
if (!PT)
|
if (!PT)
|
||||||
ThrowException("Can't store to a nonpointer type: " +
|
ThrowException("Can't store to a nonpointer type: " +
|
||||||
(*$4)->getDescription());
|
(*$5)->getDescription());
|
||||||
const Type *ElTy = PT->getElementType();
|
const Type *ElTy = PT->getElementType();
|
||||||
if (ElTy != $2->getType())
|
if (ElTy != $3->getType())
|
||||||
ThrowException("Can't store '" + $2->getType()->getDescription() +
|
ThrowException("Can't store '" + $3->getType()->getDescription() +
|
||||||
"' into space of type '" + ElTy->getDescription() + "'!");
|
"' into space of type '" + ElTy->getDescription() + "'!");
|
||||||
|
|
||||||
$$ = new StoreInst($2, getVal(*$4, $5));
|
$$ = new StoreInst($3, getVal(*$5, $6), $2);
|
||||||
delete $4;
|
delete $5;
|
||||||
}
|
}
|
||||||
| GETELEMENTPTR Types ValueRef IndexList {
|
| GETELEMENTPTR Types ValueRef IndexList {
|
||||||
if (!isa<PointerType>($2->get()))
|
if (!isa<PointerType>($2->get()))
|
||||||
|
Loading…
Reference in New Issue
Block a user