mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-15 22:28:18 +00:00
Teach the X86 backend about unreachable and undef. Among other things, we
now compile: 'foo() {}' into "ret" instead of "mov EAX, 0; ret" git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17049 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -175,6 +175,7 @@ namespace {
|
|||||||
// Control flow operators
|
// Control flow operators
|
||||||
void visitReturnInst(ReturnInst &RI);
|
void visitReturnInst(ReturnInst &RI);
|
||||||
void visitBranchInst(BranchInst &BI);
|
void visitBranchInst(BranchInst &BI);
|
||||||
|
void visitUnreachableInst(UnreachableInst &UI) {}
|
||||||
|
|
||||||
struct ValueRecord {
|
struct ValueRecord {
|
||||||
Value *Val;
|
Value *Val;
|
||||||
@@ -447,7 +448,20 @@ unsigned X86ISel::getFixedSizedAllocaFI(AllocaInst *AI) {
|
|||||||
void X86ISel::copyConstantToRegister(MachineBasicBlock *MBB,
|
void X86ISel::copyConstantToRegister(MachineBasicBlock *MBB,
|
||||||
MachineBasicBlock::iterator IP,
|
MachineBasicBlock::iterator IP,
|
||||||
Constant *C, unsigned R) {
|
Constant *C, unsigned R) {
|
||||||
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) {
|
if (isa<UndefValue>(C)) {
|
||||||
|
switch (getClassB(C->getType())) {
|
||||||
|
case cFP:
|
||||||
|
// FIXME: SHOULD TEACH STACKIFIER ABOUT UNDEF VALUES!
|
||||||
|
BuildMI(*MBB, IP, X86::FLD0, 0, R);
|
||||||
|
return;
|
||||||
|
case cLong:
|
||||||
|
BuildMI(*MBB, IP, X86::IMPLICIT_DEF, 0, R+1);
|
||||||
|
// FALL THROUGH
|
||||||
|
default:
|
||||||
|
BuildMI(*MBB, IP, X86::IMPLICIT_DEF, 0, R);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) {
|
||||||
unsigned Class = 0;
|
unsigned Class = 0;
|
||||||
switch (CE->getOpcode()) {
|
switch (CE->getOpcode()) {
|
||||||
case Instruction::GetElementPtr:
|
case Instruction::GetElementPtr:
|
||||||
|
Reference in New Issue
Block a user