mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-27 16:17:17 +00:00
Parse undef and unreachable
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17053 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -188,6 +188,7 @@ external { return EXTERNAL; }
|
|||||||
implementation { return IMPLEMENTATION; }
|
implementation { return IMPLEMENTATION; }
|
||||||
zeroinitializer { return ZEROINITIALIZER; }
|
zeroinitializer { return ZEROINITIALIZER; }
|
||||||
\.\.\. { return DOTDOTDOT; }
|
\.\.\. { return DOTDOTDOT; }
|
||||||
|
undef { return UNDEF; }
|
||||||
null { return NULL_TOK; }
|
null { return NULL_TOK; }
|
||||||
to { return TO; }
|
to { return TO; }
|
||||||
except { RET_TOK(TermOpVal, Unwind, UNWIND); }
|
except { RET_TOK(TermOpVal, Unwind, UNWIND); }
|
||||||
@@ -247,7 +248,7 @@ br { RET_TOK(TermOpVal, Br, BR); }
|
|||||||
switch { RET_TOK(TermOpVal, Switch, SWITCH); }
|
switch { RET_TOK(TermOpVal, Switch, SWITCH); }
|
||||||
invoke { RET_TOK(TermOpVal, Invoke, INVOKE); }
|
invoke { RET_TOK(TermOpVal, Invoke, INVOKE); }
|
||||||
unwind { RET_TOK(TermOpVal, Unwind, UNWIND); }
|
unwind { RET_TOK(TermOpVal, Unwind, UNWIND); }
|
||||||
|
unreachable { RET_TOK(TermOpVal, Unreachable, UNREACHABLE); }
|
||||||
|
|
||||||
malloc { RET_TOK(MemOpVal, Malloc, MALLOC); }
|
malloc { RET_TOK(MemOpVal, Malloc, MALLOC); }
|
||||||
alloca { RET_TOK(MemOpVal, Alloca, ALLOCA); }
|
alloca { RET_TOK(MemOpVal, Alloca, ALLOCA); }
|
||||||
|
@@ -72,7 +72,7 @@ static inline void ThrowException(const std::string &message,
|
|||||||
struct ValID {
|
struct ValID {
|
||||||
enum {
|
enum {
|
||||||
NumberVal, NameVal, ConstSIntVal, ConstUIntVal, ConstFPVal, ConstNullVal,
|
NumberVal, NameVal, ConstSIntVal, ConstUIntVal, ConstFPVal, ConstNullVal,
|
||||||
ConstantVal,
|
ConstUndefVal, ConstantVal,
|
||||||
} Type;
|
} Type;
|
||||||
|
|
||||||
union {
|
union {
|
||||||
@@ -108,6 +108,10 @@ struct ValID {
|
|||||||
ValID D; D.Type = ConstNullVal; return D;
|
ValID D; D.Type = ConstNullVal; return D;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ValID createUndef() {
|
||||||
|
ValID D; D.Type = ConstUndefVal; return D;
|
||||||
|
}
|
||||||
|
|
||||||
static ValID create(Constant *Val) {
|
static ValID create(Constant *Val) {
|
||||||
ValID D; D.Type = ConstantVal; D.ConstantValue = Val; return D;
|
ValID D; D.Type = ConstantVal; D.ConstantValue = Val; return D;
|
||||||
}
|
}
|
||||||
@@ -130,6 +134,7 @@ struct ValID {
|
|||||||
case NameVal : return Name;
|
case NameVal : return Name;
|
||||||
case ConstFPVal : return ftostr(ConstPoolFP);
|
case ConstFPVal : return ftostr(ConstPoolFP);
|
||||||
case ConstNullVal : return "null";
|
case ConstNullVal : return "null";
|
||||||
|
case ConstUndefVal : return "undef";
|
||||||
case ConstUIntVal :
|
case ConstUIntVal :
|
||||||
case ConstSIntVal : return std::string("%") + itostr(ConstPool64);
|
case ConstSIntVal : return std::string("%") + itostr(ConstPool64);
|
||||||
case ConstantVal:
|
case ConstantVal:
|
||||||
@@ -152,6 +157,7 @@ struct ValID {
|
|||||||
case ConstUIntVal: return UConstPool64 < V.UConstPool64;
|
case ConstUIntVal: return UConstPool64 < V.UConstPool64;
|
||||||
case ConstFPVal: return ConstPoolFP < V.ConstPoolFP;
|
case ConstFPVal: return ConstPoolFP < V.ConstPoolFP;
|
||||||
case ConstNullVal: return false;
|
case ConstNullVal: return false;
|
||||||
|
case ConstUndefVal: return false;
|
||||||
case ConstantVal: return ConstantValue < V.ConstantValue;
|
case ConstantVal: return ConstantValue < V.ConstantValue;
|
||||||
default: assert(0 && "Unknown value type!"); return false;
|
default: assert(0 && "Unknown value type!"); return false;
|
||||||
}
|
}
|
||||||
|
@@ -298,6 +298,9 @@ static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
|
|||||||
ThrowException("Cannot create a a non pointer null!");
|
ThrowException("Cannot create a a non pointer null!");
|
||||||
return ConstantPointerNull::get(cast<PointerType>(Ty));
|
return ConstantPointerNull::get(cast<PointerType>(Ty));
|
||||||
|
|
||||||
|
case ValID::ConstUndefVal: // Is it an undef value?
|
||||||
|
return UndefValue::get(Ty);
|
||||||
|
|
||||||
case ValID::ConstantVal: // Fully resolved constant?
|
case ValID::ConstantVal: // Fully resolved constant?
|
||||||
if (D.ConstantValue->getType() != Ty)
|
if (D.ConstantValue->getType() != Ty)
|
||||||
ThrowException("Constant expression type different from required type!");
|
ThrowException("Constant expression type different from required type!");
|
||||||
@@ -908,12 +911,12 @@ Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
|
|||||||
|
|
||||||
%token IMPLEMENTATION ZEROINITIALIZER TRUETOK FALSETOK BEGINTOK ENDTOK
|
%token IMPLEMENTATION ZEROINITIALIZER TRUETOK FALSETOK BEGINTOK ENDTOK
|
||||||
%token DECLARE GLOBAL CONSTANT VOLATILE
|
%token DECLARE GLOBAL CONSTANT VOLATILE
|
||||||
%token TO DOTDOTDOT NULL_TOK CONST INTERNAL LINKONCE WEAK APPENDING
|
%token TO DOTDOTDOT NULL_TOK UNDEF CONST INTERNAL LINKONCE WEAK APPENDING
|
||||||
%token OPAQUE NOT EXTERNAL TARGET TRIPLE ENDIAN POINTERSIZE LITTLE BIG
|
%token OPAQUE NOT EXTERNAL TARGET TRIPLE ENDIAN POINTERSIZE LITTLE BIG
|
||||||
%token DEPLIBS
|
%token DEPLIBS
|
||||||
|
|
||||||
// Basic Block Terminating Operators
|
// Basic Block Terminating Operators
|
||||||
%token <TermOpVal> RET BR SWITCH INVOKE UNWIND
|
%token <TermOpVal> RET BR SWITCH INVOKE UNWIND UNREACHABLE
|
||||||
|
|
||||||
// Binary Operators
|
// Binary Operators
|
||||||
%type <BinaryOpVal> ArithmeticOps LogicalOps SetCondOps // Binops Subcatagories
|
%type <BinaryOpVal> ArithmeticOps LogicalOps SetCondOps // Binops Subcatagories
|
||||||
@@ -1221,6 +1224,10 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr
|
|||||||
$$ = ConstantPointerNull::get(PTy);
|
$$ = ConstantPointerNull::get(PTy);
|
||||||
delete $1;
|
delete $1;
|
||||||
}
|
}
|
||||||
|
| Types UNDEF {
|
||||||
|
$$ = UndefValue::get($1->get());
|
||||||
|
delete $1;
|
||||||
|
}
|
||||||
| Types SymbolicValueRef {
|
| Types SymbolicValueRef {
|
||||||
const PointerType *Ty = dyn_cast<PointerType>($1->get());
|
const PointerType *Ty = dyn_cast<PointerType>($1->get());
|
||||||
if (Ty == 0)
|
if (Ty == 0)
|
||||||
@@ -1687,6 +1694,9 @@ ConstValueRef : ESINT64VAL { // A reference to a direct constant
|
|||||||
| NULL_TOK {
|
| NULL_TOK {
|
||||||
$$ = ValID::createNull();
|
$$ = ValID::createNull();
|
||||||
}
|
}
|
||||||
|
| UNDEF {
|
||||||
|
$$ = ValID::createUndef();
|
||||||
|
}
|
||||||
| '<' ConstVector '>' { // Nonempty unsized packed vector
|
| '<' ConstVector '>' { // Nonempty unsized packed vector
|
||||||
const Type *ETy = (*$2)[0]->getType();
|
const Type *ETy = (*$2)[0]->getType();
|
||||||
int NumElements = $2->size();
|
int NumElements = $2->size();
|
||||||
@@ -1858,6 +1868,9 @@ BBTerminatorInst : RET ResolvedVal { // Return with a result...
|
|||||||
}
|
}
|
||||||
| UNWIND {
|
| UNWIND {
|
||||||
$$ = new UnwindInst();
|
$$ = new UnwindInst();
|
||||||
|
}
|
||||||
|
| UNREACHABLE {
|
||||||
|
$$ = new UnreachableInst();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user