mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-29 13:24:25 +00:00
First version of code to handle loads. Stub function for handling stores.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12758 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -61,7 +61,9 @@ namespace {
|
|||||||
void visitShiftInstruction(Instruction &I) { visitBinaryOperator(I); }
|
void visitShiftInstruction(Instruction &I) { visitBinaryOperator(I); }
|
||||||
void visitSetCondInst(Instruction &I);
|
void visitSetCondInst(Instruction &I);
|
||||||
void visitCallInst(CallInst &I);
|
void visitCallInst(CallInst &I);
|
||||||
void visitReturnInst(ReturnInst &RI);
|
void visitReturnInst(ReturnInst &I);
|
||||||
|
void visitLoadInst(LoadInst &I);
|
||||||
|
void visitStoreInst(StoreInst &I);
|
||||||
|
|
||||||
void visitInstruction(Instruction &I) {
|
void visitInstruction(Instruction &I) {
|
||||||
std::cerr << "Unhandled instruction: " << I;
|
std::cerr << "Unhandled instruction: " << I;
|
||||||
@ -280,6 +282,42 @@ bool V8ISel::runOnFunction(Function &Fn) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void V8ISel::visitLoadInst(LoadInst &I) {
|
||||||
|
unsigned DestReg = getReg (I);
|
||||||
|
unsigned PtrReg = getReg (I.getOperand (0));
|
||||||
|
switch (getClass (I.getType ())) {
|
||||||
|
case cByte:
|
||||||
|
if (I.getType ()->isSigned ())
|
||||||
|
BuildMI (BB, V8::LDSBmr, 1, DestReg).addReg (PtrReg).addSImm(0);
|
||||||
|
else
|
||||||
|
BuildMI (BB, V8::LDUBmr, 1, DestReg).addReg (PtrReg).addSImm(0);
|
||||||
|
return;
|
||||||
|
case cShort:
|
||||||
|
if (I.getType ()->isSigned ())
|
||||||
|
BuildMI (BB, V8::LDSHmr, 1, DestReg).addReg (PtrReg).addSImm(0);
|
||||||
|
else
|
||||||
|
BuildMI (BB, V8::LDUHmr, 1, DestReg).addReg (PtrReg).addSImm(0);
|
||||||
|
return;
|
||||||
|
case cInt:
|
||||||
|
BuildMI (BB, V8::LDmr, 1, DestReg).addReg (PtrReg).addSImm(0);
|
||||||
|
return;
|
||||||
|
case cLong:
|
||||||
|
BuildMI (BB, V8::LDDmr, 1, DestReg).addReg (PtrReg).addSImm(0);
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
std::cerr << "Load instruction not handled: " << I;
|
||||||
|
abort ();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void V8ISel::visitStoreInst(StoreInst &I) {
|
||||||
|
unsigned SrcReg = getReg (I.getOperand (0));
|
||||||
|
unsigned PtrReg = getReg (I.getOperand (1));
|
||||||
|
std::cerr << "Store instruction not handled: " << I;
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
|
||||||
void V8ISel::visitCallInst(CallInst &I) {
|
void V8ISel::visitCallInst(CallInst &I) {
|
||||||
assert (I.getNumOperands () < 8
|
assert (I.getNumOperands () < 8
|
||||||
&& "Can't handle pushing excess call args on the stack yet");
|
&& "Can't handle pushing excess call args on the stack yet");
|
||||||
|
@ -61,7 +61,9 @@ namespace {
|
|||||||
void visitShiftInstruction(Instruction &I) { visitBinaryOperator(I); }
|
void visitShiftInstruction(Instruction &I) { visitBinaryOperator(I); }
|
||||||
void visitSetCondInst(Instruction &I);
|
void visitSetCondInst(Instruction &I);
|
||||||
void visitCallInst(CallInst &I);
|
void visitCallInst(CallInst &I);
|
||||||
void visitReturnInst(ReturnInst &RI);
|
void visitReturnInst(ReturnInst &I);
|
||||||
|
void visitLoadInst(LoadInst &I);
|
||||||
|
void visitStoreInst(StoreInst &I);
|
||||||
|
|
||||||
void visitInstruction(Instruction &I) {
|
void visitInstruction(Instruction &I) {
|
||||||
std::cerr << "Unhandled instruction: " << I;
|
std::cerr << "Unhandled instruction: " << I;
|
||||||
@ -280,6 +282,42 @@ bool V8ISel::runOnFunction(Function &Fn) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void V8ISel::visitLoadInst(LoadInst &I) {
|
||||||
|
unsigned DestReg = getReg (I);
|
||||||
|
unsigned PtrReg = getReg (I.getOperand (0));
|
||||||
|
switch (getClass (I.getType ())) {
|
||||||
|
case cByte:
|
||||||
|
if (I.getType ()->isSigned ())
|
||||||
|
BuildMI (BB, V8::LDSBmr, 1, DestReg).addReg (PtrReg).addSImm(0);
|
||||||
|
else
|
||||||
|
BuildMI (BB, V8::LDUBmr, 1, DestReg).addReg (PtrReg).addSImm(0);
|
||||||
|
return;
|
||||||
|
case cShort:
|
||||||
|
if (I.getType ()->isSigned ())
|
||||||
|
BuildMI (BB, V8::LDSHmr, 1, DestReg).addReg (PtrReg).addSImm(0);
|
||||||
|
else
|
||||||
|
BuildMI (BB, V8::LDUHmr, 1, DestReg).addReg (PtrReg).addSImm(0);
|
||||||
|
return;
|
||||||
|
case cInt:
|
||||||
|
BuildMI (BB, V8::LDmr, 1, DestReg).addReg (PtrReg).addSImm(0);
|
||||||
|
return;
|
||||||
|
case cLong:
|
||||||
|
BuildMI (BB, V8::LDDmr, 1, DestReg).addReg (PtrReg).addSImm(0);
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
std::cerr << "Load instruction not handled: " << I;
|
||||||
|
abort ();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void V8ISel::visitStoreInst(StoreInst &I) {
|
||||||
|
unsigned SrcReg = getReg (I.getOperand (0));
|
||||||
|
unsigned PtrReg = getReg (I.getOperand (1));
|
||||||
|
std::cerr << "Store instruction not handled: " << I;
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
|
||||||
void V8ISel::visitCallInst(CallInst &I) {
|
void V8ISel::visitCallInst(CallInst &I) {
|
||||||
assert (I.getNumOperands () < 8
|
assert (I.getNumOperands () < 8
|
||||||
&& "Can't handle pushing excess call args on the stack yet");
|
&& "Can't handle pushing excess call args on the stack yet");
|
||||||
|
@ -61,7 +61,9 @@ namespace {
|
|||||||
void visitShiftInstruction(Instruction &I) { visitBinaryOperator(I); }
|
void visitShiftInstruction(Instruction &I) { visitBinaryOperator(I); }
|
||||||
void visitSetCondInst(Instruction &I);
|
void visitSetCondInst(Instruction &I);
|
||||||
void visitCallInst(CallInst &I);
|
void visitCallInst(CallInst &I);
|
||||||
void visitReturnInst(ReturnInst &RI);
|
void visitReturnInst(ReturnInst &I);
|
||||||
|
void visitLoadInst(LoadInst &I);
|
||||||
|
void visitStoreInst(StoreInst &I);
|
||||||
|
|
||||||
void visitInstruction(Instruction &I) {
|
void visitInstruction(Instruction &I) {
|
||||||
std::cerr << "Unhandled instruction: " << I;
|
std::cerr << "Unhandled instruction: " << I;
|
||||||
@ -280,6 +282,42 @@ bool V8ISel::runOnFunction(Function &Fn) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void V8ISel::visitLoadInst(LoadInst &I) {
|
||||||
|
unsigned DestReg = getReg (I);
|
||||||
|
unsigned PtrReg = getReg (I.getOperand (0));
|
||||||
|
switch (getClass (I.getType ())) {
|
||||||
|
case cByte:
|
||||||
|
if (I.getType ()->isSigned ())
|
||||||
|
BuildMI (BB, V8::LDSBmr, 1, DestReg).addReg (PtrReg).addSImm(0);
|
||||||
|
else
|
||||||
|
BuildMI (BB, V8::LDUBmr, 1, DestReg).addReg (PtrReg).addSImm(0);
|
||||||
|
return;
|
||||||
|
case cShort:
|
||||||
|
if (I.getType ()->isSigned ())
|
||||||
|
BuildMI (BB, V8::LDSHmr, 1, DestReg).addReg (PtrReg).addSImm(0);
|
||||||
|
else
|
||||||
|
BuildMI (BB, V8::LDUHmr, 1, DestReg).addReg (PtrReg).addSImm(0);
|
||||||
|
return;
|
||||||
|
case cInt:
|
||||||
|
BuildMI (BB, V8::LDmr, 1, DestReg).addReg (PtrReg).addSImm(0);
|
||||||
|
return;
|
||||||
|
case cLong:
|
||||||
|
BuildMI (BB, V8::LDDmr, 1, DestReg).addReg (PtrReg).addSImm(0);
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
std::cerr << "Load instruction not handled: " << I;
|
||||||
|
abort ();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void V8ISel::visitStoreInst(StoreInst &I) {
|
||||||
|
unsigned SrcReg = getReg (I.getOperand (0));
|
||||||
|
unsigned PtrReg = getReg (I.getOperand (1));
|
||||||
|
std::cerr << "Store instruction not handled: " << I;
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
|
||||||
void V8ISel::visitCallInst(CallInst &I) {
|
void V8ISel::visitCallInst(CallInst &I) {
|
||||||
assert (I.getNumOperands () < 8
|
assert (I.getNumOperands () < 8
|
||||||
&& "Can't handle pushing excess call args on the stack yet");
|
&& "Can't handle pushing excess call args on the stack yet");
|
||||||
|
@ -61,7 +61,9 @@ namespace {
|
|||||||
void visitShiftInstruction(Instruction &I) { visitBinaryOperator(I); }
|
void visitShiftInstruction(Instruction &I) { visitBinaryOperator(I); }
|
||||||
void visitSetCondInst(Instruction &I);
|
void visitSetCondInst(Instruction &I);
|
||||||
void visitCallInst(CallInst &I);
|
void visitCallInst(CallInst &I);
|
||||||
void visitReturnInst(ReturnInst &RI);
|
void visitReturnInst(ReturnInst &I);
|
||||||
|
void visitLoadInst(LoadInst &I);
|
||||||
|
void visitStoreInst(StoreInst &I);
|
||||||
|
|
||||||
void visitInstruction(Instruction &I) {
|
void visitInstruction(Instruction &I) {
|
||||||
std::cerr << "Unhandled instruction: " << I;
|
std::cerr << "Unhandled instruction: " << I;
|
||||||
@ -280,6 +282,42 @@ bool V8ISel::runOnFunction(Function &Fn) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void V8ISel::visitLoadInst(LoadInst &I) {
|
||||||
|
unsigned DestReg = getReg (I);
|
||||||
|
unsigned PtrReg = getReg (I.getOperand (0));
|
||||||
|
switch (getClass (I.getType ())) {
|
||||||
|
case cByte:
|
||||||
|
if (I.getType ()->isSigned ())
|
||||||
|
BuildMI (BB, V8::LDSBmr, 1, DestReg).addReg (PtrReg).addSImm(0);
|
||||||
|
else
|
||||||
|
BuildMI (BB, V8::LDUBmr, 1, DestReg).addReg (PtrReg).addSImm(0);
|
||||||
|
return;
|
||||||
|
case cShort:
|
||||||
|
if (I.getType ()->isSigned ())
|
||||||
|
BuildMI (BB, V8::LDSHmr, 1, DestReg).addReg (PtrReg).addSImm(0);
|
||||||
|
else
|
||||||
|
BuildMI (BB, V8::LDUHmr, 1, DestReg).addReg (PtrReg).addSImm(0);
|
||||||
|
return;
|
||||||
|
case cInt:
|
||||||
|
BuildMI (BB, V8::LDmr, 1, DestReg).addReg (PtrReg).addSImm(0);
|
||||||
|
return;
|
||||||
|
case cLong:
|
||||||
|
BuildMI (BB, V8::LDDmr, 1, DestReg).addReg (PtrReg).addSImm(0);
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
std::cerr << "Load instruction not handled: " << I;
|
||||||
|
abort ();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void V8ISel::visitStoreInst(StoreInst &I) {
|
||||||
|
unsigned SrcReg = getReg (I.getOperand (0));
|
||||||
|
unsigned PtrReg = getReg (I.getOperand (1));
|
||||||
|
std::cerr << "Store instruction not handled: " << I;
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
|
||||||
void V8ISel::visitCallInst(CallInst &I) {
|
void V8ISel::visitCallInst(CallInst &I) {
|
||||||
assert (I.getNumOperands () < 8
|
assert (I.getNumOperands () < 8
|
||||||
&& "Can't handle pushing excess call args on the stack yet");
|
&& "Can't handle pushing excess call args on the stack yet");
|
||||||
|
Reference in New Issue
Block a user