mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-15 07:39:31 +00:00
Add simple reg-reg and reg-imm moves
llvm-svn: 75912
This commit is contained in:
parent
7fe1d9c90e
commit
7b8aec2c40
@ -168,5 +168,20 @@ void SystemZAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
|
||||
|
||||
void SystemZAsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
|
||||
const char* Modifier) {
|
||||
assert(0 && "Not implemented yet!");
|
||||
const MachineOperand &MO = MI->getOperand(OpNum);
|
||||
switch (MO.getType()) {
|
||||
case MachineOperand::MO_Register:
|
||||
assert (TargetRegisterInfo::isPhysicalRegister(MO.getReg()) &&
|
||||
"Virtual registers should be already mapped!");
|
||||
O << '%' << TM.getRegisterInfo()->get(MO.getReg()).AsmName;
|
||||
return;
|
||||
case MachineOperand::MO_Immediate:
|
||||
O << MO.getImm();
|
||||
return;
|
||||
case MachineOperand::MO_MachineBasicBlock:
|
||||
printBasicBlockLabel(MO.getMBB());
|
||||
return;
|
||||
default:
|
||||
assert(0 && "Not implemented yet!");
|
||||
}
|
||||
}
|
||||
|
@ -43,18 +43,46 @@ void SystemZInstrInfo::loadRegFromStackSlot(MachineBasicBlock &MBB,
|
||||
}
|
||||
|
||||
bool SystemZInstrInfo::copyRegToReg(MachineBasicBlock &MBB,
|
||||
MachineBasicBlock::iterator I,
|
||||
unsigned DestReg, unsigned SrcReg,
|
||||
const TargetRegisterClass *DestRC,
|
||||
const TargetRegisterClass *SrcRC) const {
|
||||
MachineBasicBlock::iterator I,
|
||||
unsigned DestReg, unsigned SrcReg,
|
||||
const TargetRegisterClass *DestRC,
|
||||
const TargetRegisterClass *SrcRC) const {
|
||||
DebugLoc DL = DebugLoc::getUnknownLoc();
|
||||
if (I != MBB.end()) DL = I->getDebugLoc();
|
||||
|
||||
if (DestRC == SrcRC) {
|
||||
unsigned Opc;
|
||||
if (DestRC == &SystemZ::GR64RegClass) {
|
||||
Opc = SystemZ::MOV64rr;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
BuildMI(MBB, I, DL, get(Opc), DestReg).addReg(SrcReg);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
SystemZInstrInfo::isMoveInstr(const MachineInstr& MI,
|
||||
unsigned &SrcReg, unsigned &DstReg,
|
||||
unsigned &SrcSubIdx, unsigned &DstSubIdx) const {
|
||||
return false;
|
||||
unsigned &SrcReg, unsigned &DstReg,
|
||||
unsigned &SrcSubIdx, unsigned &DstSubIdx) const {
|
||||
SrcSubIdx = DstSubIdx = 0; // No sub-registers yet.
|
||||
|
||||
switch (MI.getOpcode()) {
|
||||
default:
|
||||
return false;
|
||||
case SystemZ::MOV64rr:
|
||||
assert(MI.getNumOperands() >= 2 &&
|
||||
MI.getOperand(0).isReg() &&
|
||||
MI.getOperand(1).isReg() &&
|
||||
"invalid register-register move instruction");
|
||||
SrcReg = MI.getOperand(1).getReg();
|
||||
DstReg = MI.getOperand(0).getReg();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -30,3 +30,20 @@ def NOP : Pseudo<(outs), (ins), "# no-op", []>;
|
||||
let isReturn = 1, isTerminator = 1 in {
|
||||
def RET : Pseudo<(outs), (ins), "br\t%r14", [(SystemZretflag)]>;
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Move Instructions
|
||||
|
||||
// FIXME: Provide proper encoding!
|
||||
let neverHasSideEffects = 1 in {
|
||||
def MOV64rr : Pseudo<(outs GR64:$dst), (ins GR64:$src),
|
||||
"lgr\t{$dst, $src}",
|
||||
[]>;
|
||||
}
|
||||
|
||||
// FIXME: Provide proper encoding!
|
||||
let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
|
||||
def MOV64ri : Pseudo<(outs GR64:$dst), (ins i64imm:$src),
|
||||
"lghi\t{$dst, $src}",
|
||||
[(set GR64:$dst, imm:$src)]>;
|
||||
}
|
||||
|
6
test/CodeGen/SystemZ/01-RetArg.ll
Normal file
6
test/CodeGen/SystemZ/01-RetArg.ll
Normal file
@ -0,0 +1,6 @@
|
||||
; RUN: llvm-as < %s | llc -march=systemz
|
||||
|
||||
define i64 @foo(i64 %a, i64 %b) {
|
||||
entry:
|
||||
ret i64 %b
|
||||
}
|
6
test/CodeGen/SystemZ/01-RetImm.ll
Normal file
6
test/CodeGen/SystemZ/01-RetImm.ll
Normal file
@ -0,0 +1,6 @@
|
||||
; RUN: llvm-as < %s | llc -march=systemz
|
||||
|
||||
define i64 @foo() {
|
||||
entry:
|
||||
ret i64 0
|
||||
}
|
Loading…
Reference in New Issue
Block a user