mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-23 20:29:30 +00:00
[X86 fast-isel] Constrain the index reg class to not include SP.
The index reg on instructions with complex address modes is a GPR64_NOSP. Constrain it to appease the machine verifier. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236557 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
000e7d10e8
commit
9fb69672d6
@ -83,13 +83,13 @@ public:
|
|||||||
private:
|
private:
|
||||||
bool X86FastEmitCompare(const Value *LHS, const Value *RHS, EVT VT, DebugLoc DL);
|
bool X86FastEmitCompare(const Value *LHS, const Value *RHS, EVT VT, DebugLoc DL);
|
||||||
|
|
||||||
bool X86FastEmitLoad(EVT VT, const X86AddressMode &AM, MachineMemOperand *MMO,
|
bool X86FastEmitLoad(EVT VT, X86AddressMode &AM, MachineMemOperand *MMO,
|
||||||
unsigned &ResultReg, unsigned Alignment = 1);
|
unsigned &ResultReg, unsigned Alignment = 1);
|
||||||
|
|
||||||
bool X86FastEmitStore(EVT VT, const Value *Val, const X86AddressMode &AM,
|
bool X86FastEmitStore(EVT VT, const Value *Val, X86AddressMode &AM,
|
||||||
MachineMemOperand *MMO = nullptr, bool Aligned = false);
|
MachineMemOperand *MMO = nullptr, bool Aligned = false);
|
||||||
bool X86FastEmitStore(EVT VT, unsigned ValReg, bool ValIsKill,
|
bool X86FastEmitStore(EVT VT, unsigned ValReg, bool ValIsKill,
|
||||||
const X86AddressMode &AM,
|
X86AddressMode &AM,
|
||||||
MachineMemOperand *MMO = nullptr, bool Aligned = false);
|
MachineMemOperand *MMO = nullptr, bool Aligned = false);
|
||||||
|
|
||||||
bool X86FastEmitExtend(ISD::NodeType Opc, EVT DstVT, unsigned Src, EVT SrcVT,
|
bool X86FastEmitExtend(ISD::NodeType Opc, EVT DstVT, unsigned Src, EVT SrcVT,
|
||||||
@ -165,6 +165,9 @@ private:
|
|||||||
|
|
||||||
bool foldX86XALUIntrinsic(X86::CondCode &CC, const Instruction *I,
|
bool foldX86XALUIntrinsic(X86::CondCode &CC, const Instruction *I,
|
||||||
const Value *Cond);
|
const Value *Cond);
|
||||||
|
|
||||||
|
const MachineInstrBuilder &addFullAddress(const MachineInstrBuilder &MIB,
|
||||||
|
X86AddressMode &AM);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end anonymous namespace.
|
} // end anonymous namespace.
|
||||||
@ -242,6 +245,20 @@ getX86SSEConditionCode(CmpInst::Predicate Predicate) {
|
|||||||
return std::make_pair(CC, NeedSwap);
|
return std::make_pair(CC, NeedSwap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \brief Adds a complex addressing mode to the given machine instr builder.
|
||||||
|
/// Note, this will constrain the index register. If its not possible to
|
||||||
|
/// constrain the given index register, then a new one will be created. The
|
||||||
|
/// IndexReg field of the addressing mode will be updated to match in this case.
|
||||||
|
const MachineInstrBuilder &
|
||||||
|
X86FastISel::addFullAddress(const MachineInstrBuilder &MIB,
|
||||||
|
X86AddressMode &AM) {
|
||||||
|
// First constrain the index register. It needs to be a GR64_NOSP.
|
||||||
|
AM.IndexReg = constrainOperandRegClass(MIB->getDesc(), AM.IndexReg,
|
||||||
|
MIB->getNumOperands() +
|
||||||
|
X86::AddrIndexReg);
|
||||||
|
return ::addFullAddress(MIB, AM);
|
||||||
|
}
|
||||||
|
|
||||||
/// \brief Check if it is possible to fold the condition from the XALU intrinsic
|
/// \brief Check if it is possible to fold the condition from the XALU intrinsic
|
||||||
/// into the user. The condition code will only be updated on success.
|
/// into the user. The condition code will only be updated on success.
|
||||||
bool X86FastISel::foldX86XALUIntrinsic(X86::CondCode &CC, const Instruction *I,
|
bool X86FastISel::foldX86XALUIntrinsic(X86::CondCode &CC, const Instruction *I,
|
||||||
@ -326,7 +343,7 @@ bool X86FastISel::isTypeLegal(Type *Ty, MVT &VT, bool AllowI1) {
|
|||||||
/// X86FastEmitLoad - Emit a machine instruction to load a value of type VT.
|
/// X86FastEmitLoad - Emit a machine instruction to load a value of type VT.
|
||||||
/// The address is either pre-computed, i.e. Ptr, or a GlobalAddress, i.e. GV.
|
/// The address is either pre-computed, i.e. Ptr, or a GlobalAddress, i.e. GV.
|
||||||
/// Return true and the result register by reference if it is possible.
|
/// Return true and the result register by reference if it is possible.
|
||||||
bool X86FastISel::X86FastEmitLoad(EVT VT, const X86AddressMode &AM,
|
bool X86FastISel::X86FastEmitLoad(EVT VT, X86AddressMode &AM,
|
||||||
MachineMemOperand *MMO, unsigned &ResultReg,
|
MachineMemOperand *MMO, unsigned &ResultReg,
|
||||||
unsigned Alignment) {
|
unsigned Alignment) {
|
||||||
// Get opcode and regclass of the output for the given load instruction.
|
// Get opcode and regclass of the output for the given load instruction.
|
||||||
@ -413,7 +430,7 @@ bool X86FastISel::X86FastEmitLoad(EVT VT, const X86AddressMode &AM,
|
|||||||
/// and a displacement offset, or a GlobalAddress,
|
/// and a displacement offset, or a GlobalAddress,
|
||||||
/// i.e. V. Return true if it is possible.
|
/// i.e. V. Return true if it is possible.
|
||||||
bool X86FastISel::X86FastEmitStore(EVT VT, unsigned ValReg, bool ValIsKill,
|
bool X86FastISel::X86FastEmitStore(EVT VT, unsigned ValReg, bool ValIsKill,
|
||||||
const X86AddressMode &AM,
|
X86AddressMode &AM,
|
||||||
MachineMemOperand *MMO, bool Aligned) {
|
MachineMemOperand *MMO, bool Aligned) {
|
||||||
// Get opcode and regclass of the output for the given store instruction.
|
// Get opcode and regclass of the output for the given store instruction.
|
||||||
unsigned Opc = 0;
|
unsigned Opc = 0;
|
||||||
@ -474,7 +491,7 @@ bool X86FastISel::X86FastEmitStore(EVT VT, unsigned ValReg, bool ValIsKill,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool X86FastISel::X86FastEmitStore(EVT VT, const Value *Val,
|
bool X86FastISel::X86FastEmitStore(EVT VT, const Value *Val,
|
||||||
const X86AddressMode &AM,
|
X86AddressMode &AM,
|
||||||
MachineMemOperand *MMO, bool Aligned) {
|
MachineMemOperand *MMO, bool Aligned) {
|
||||||
// Handle 'null' like i32/i64 0.
|
// Handle 'null' like i32/i64 0.
|
||||||
if (isa<ConstantPointerNull>(Val))
|
if (isa<ConstantPointerNull>(Val))
|
||||||
|
25
test/CodeGen/X86/fast-isel-constrain-store-indexreg.ll
Normal file
25
test/CodeGen/X86/fast-isel-constrain-store-indexreg.ll
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
; RUN: llc %s -o - -verify-machineinstrs | FileCheck %s
|
||||||
|
|
||||||
|
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
|
||||||
|
target triple = "x86_64-apple-unknown"
|
||||||
|
|
||||||
|
@TheArray = external global [100000 x double], align 16
|
||||||
|
|
||||||
|
; This test ensures, via the machine verifier, that the register class for the
|
||||||
|
; index of the double store is correctly constrained to not include SP.
|
||||||
|
|
||||||
|
; CHECK: movsd
|
||||||
|
|
||||||
|
define i32 @main(i32* %i, double %tmpv) {
|
||||||
|
bb:
|
||||||
|
br label %bb7
|
||||||
|
|
||||||
|
bb7: ; preds = %bb7, %bb
|
||||||
|
%storemerge = phi i32 [ 0, %bb ], [ %tmp19, %bb7 ]
|
||||||
|
%tmp15 = zext i32 %storemerge to i64
|
||||||
|
%tmp16 = getelementptr inbounds [100000 x double], [100000 x double]* @TheArray, i64 0, i64 %tmp15
|
||||||
|
store double %tmpv, double* %tmp16, align 8
|
||||||
|
%tmp18 = load i32, i32* %i, align 4
|
||||||
|
%tmp19 = add i32 %tmp18, 1
|
||||||
|
br label %bb7
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user