mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-27 14:34:58 +00:00
Add support for fast isel of (integer) immediate materialization pattens, and use them to support
bitcast of constants in fast isel. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55325 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8bb2ef4760
commit
6d0c25ec3a
@ -81,11 +81,6 @@ protected:
|
|||||||
ISD::NodeType Opcode,
|
ISD::NodeType Opcode,
|
||||||
unsigned Op0, unsigned Op1);
|
unsigned Op0, unsigned Op1);
|
||||||
|
|
||||||
/// FastEmit_i - This method is called by target-independent code
|
|
||||||
/// to request that an instruction with the given type which materialize
|
|
||||||
/// the specified immediate value.
|
|
||||||
virtual unsigned FastEmit_i(MVT::SimpleValueType VT, uint64_t Imm);
|
|
||||||
|
|
||||||
/// FastEmit_ri - This method is called by target-independent code
|
/// FastEmit_ri - This method is called by target-independent code
|
||||||
/// to request that an instruction with the given type, opcode, and
|
/// to request that an instruction with the given type, opcode, and
|
||||||
/// register and immediate operands be emitted.
|
/// register and immediate operands be emitted.
|
||||||
@ -110,6 +105,13 @@ protected:
|
|||||||
ISD::NodeType Opcode,
|
ISD::NodeType Opcode,
|
||||||
unsigned Op0, uint64_t Imm,
|
unsigned Op0, uint64_t Imm,
|
||||||
MVT::SimpleValueType ImmType);
|
MVT::SimpleValueType ImmType);
|
||||||
|
|
||||||
|
/// FastEmit_i - This method is called by target-independent code
|
||||||
|
/// to request that an instruction with the given type, opcode, and
|
||||||
|
/// immediate operand be emitted.
|
||||||
|
virtual unsigned FastEmit_i(MVT::SimpleValueType VT,
|
||||||
|
ISD::NodeType Opcode,
|
||||||
|
uint64_t Imm);
|
||||||
|
|
||||||
/// FastEmitInst_ - Emit a MachineInstr with no operands and a
|
/// FastEmitInst_ - Emit a MachineInstr with no operands and a
|
||||||
/// result register in the given register class.
|
/// result register in the given register class.
|
||||||
@ -144,6 +146,12 @@ protected:
|
|||||||
unsigned FastEmitInst_rri(unsigned MachineInstOpcode,
|
unsigned FastEmitInst_rri(unsigned MachineInstOpcode,
|
||||||
const TargetRegisterClass *RC,
|
const TargetRegisterClass *RC,
|
||||||
unsigned Op0, unsigned Op1, uint64_t Imm);
|
unsigned Op0, unsigned Op1, uint64_t Imm);
|
||||||
|
|
||||||
|
/// FastEmitInst_i - Emit a MachineInstr with a single immediate
|
||||||
|
/// operand, and a result register in the given register class.
|
||||||
|
unsigned FastEmitInst_i(unsigned MachineInstrOpcode,
|
||||||
|
const TargetRegisterClass *RC,
|
||||||
|
uint64_t Imm);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned createResultReg(const TargetRegisterClass *RC);
|
unsigned createResultReg(const TargetRegisterClass *RC);
|
||||||
|
@ -221,6 +221,22 @@ FastISel::SelectInstructions(BasicBlock::iterator Begin,
|
|||||||
case Instruction::PHI:
|
case Instruction::PHI:
|
||||||
// PHI nodes are already emitted.
|
// PHI nodes are already emitted.
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Instruction::BitCast:
|
||||||
|
// BitCast consists of either an immediate to register move
|
||||||
|
// or a register to register move.
|
||||||
|
if (ConstantInt* CI = dyn_cast<ConstantInt>(I->getOperand(0))) {
|
||||||
|
if (I->getType()->isInteger()) {
|
||||||
|
MVT VT = MVT::getMVT(I->getType(), /*HandleUnknown=*/false);
|
||||||
|
ValueMap[I] = FastEmit_i(VT.getSimpleVT(), ISD::Constant,
|
||||||
|
CI->getZExtValue());
|
||||||
|
break;
|
||||||
|
} else
|
||||||
|
// TODO: Support vector and fp constants.
|
||||||
|
return I;
|
||||||
|
} else
|
||||||
|
// TODO: Support non-constant bitcasts.
|
||||||
|
return I;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// Unhandled instruction. Halt "fast" selection and bail.
|
// Unhandled instruction. Halt "fast" selection and bail.
|
||||||
@ -256,7 +272,8 @@ unsigned FastISel::FastEmit_rr(MVT::SimpleValueType, ISD::NodeType,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned FastISel::FastEmit_i(MVT::SimpleValueType, uint64_t /*Imm*/) {
|
unsigned FastISel::FastEmit_i(MVT::SimpleValueType, ISD::NodeType,
|
||||||
|
uint64_t /*Imm*/) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,7 +301,7 @@ unsigned FastISel::FastEmit_ri_(MVT::SimpleValueType VT, ISD::NodeType Opcode,
|
|||||||
ResultReg = FastEmit_ri(VT, Opcode, Op0, Imm);
|
ResultReg = FastEmit_ri(VT, Opcode, Op0, Imm);
|
||||||
if (ResultReg != 0)
|
if (ResultReg != 0)
|
||||||
return ResultReg;
|
return ResultReg;
|
||||||
unsigned MaterialReg = FastEmit_i(ImmType, Imm);
|
unsigned MaterialReg = FastEmit_i(ImmType, ISD::Constant, Imm);
|
||||||
if (MaterialReg == 0)
|
if (MaterialReg == 0)
|
||||||
return 0;
|
return 0;
|
||||||
return FastEmit_rr(VT, Opcode, Op0, MaterialReg);
|
return FastEmit_rr(VT, Opcode, Op0, MaterialReg);
|
||||||
@ -342,3 +359,13 @@ unsigned FastISel::FastEmitInst_rri(unsigned MachineInstOpcode,
|
|||||||
BuildMI(MBB, II, ResultReg).addReg(Op0).addReg(Op1).addImm(Imm);
|
BuildMI(MBB, II, ResultReg).addReg(Op0).addReg(Op1).addImm(Imm);
|
||||||
return ResultReg;
|
return ResultReg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned FastISel::FastEmitInst_i(unsigned MachineInstOpcode,
|
||||||
|
const TargetRegisterClass *RC,
|
||||||
|
uint64_t Imm) {
|
||||||
|
unsigned ResultReg = createResultReg(RC);
|
||||||
|
const TargetInstrDesc &II = TII.get(MachineInstOpcode);
|
||||||
|
|
||||||
|
BuildMI(MBB, II, ResultReg).addImm(Imm);
|
||||||
|
return ResultReg;
|
||||||
|
}
|
@ -41,3 +41,8 @@ exit:
|
|||||||
ret double %t2
|
ret double %t2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
define i32 @cast(){
|
||||||
|
entry:
|
||||||
|
%tmp2 = bitcast i32 0 to i32
|
||||||
|
ret i32 %tmp2
|
||||||
|
}
|
||||||
|
@ -64,6 +64,12 @@ struct OperandsSignature {
|
|||||||
const CodeGenTarget &Target,
|
const CodeGenTarget &Target,
|
||||||
MVT::SimpleValueType VT,
|
MVT::SimpleValueType VT,
|
||||||
const CodeGenRegisterClass *DstRC) {
|
const CodeGenRegisterClass *DstRC) {
|
||||||
|
if (!InstPatNode->isLeaf() &&
|
||||||
|
InstPatNode->getOperator()->getName() == "imm") {
|
||||||
|
Operands.push_back("i");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
for (unsigned i = 0, e = InstPatNode->getNumChildren(); i != e; ++i) {
|
for (unsigned i = 0, e = InstPatNode->getNumChildren(); i != e; ++i) {
|
||||||
TreePatternNode *Op = InstPatNode->getChild(i);
|
TreePatternNode *Op = InstPatNode->getChild(i);
|
||||||
// For now, filter out any operand with a predicate.
|
// For now, filter out any operand with a predicate.
|
||||||
@ -219,9 +225,6 @@ void FastISelEmitter::run(std::ostream &OS) {
|
|||||||
// an Operand or an immediate, like MOV32ri.
|
// an Operand or an immediate, like MOV32ri.
|
||||||
if (InstPatOp->isSubClassOf("Operand"))
|
if (InstPatOp->isSubClassOf("Operand"))
|
||||||
continue;
|
continue;
|
||||||
if (InstPatOp->getName() == "imm" ||
|
|
||||||
InstPatOp->getName() == "fpimm")
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// For now, filter out any instructions with predicates.
|
// For now, filter out any instructions with predicates.
|
||||||
if (!InstPatNode->getPredicateFn().empty())
|
if (!InstPatNode->getPredicateFn().empty())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user