mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-28 09:31:03 +00:00
Reduce casting in various tables by defining the table
with the right types. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116001 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
256f9604f1
commit
45a1cb26a3
@ -216,12 +216,12 @@ X86InstrInfo::X86InstrInfo(X86TargetMachine &tm)
|
|||||||
for (unsigned i = 0, e = array_lengthof(OpTbl2Addr); i != e; ++i) {
|
for (unsigned i = 0, e = array_lengthof(OpTbl2Addr); i != e; ++i) {
|
||||||
unsigned RegOp = OpTbl2Addr[i][0];
|
unsigned RegOp = OpTbl2Addr[i][0];
|
||||||
unsigned MemOp = OpTbl2Addr[i][1];
|
unsigned MemOp = OpTbl2Addr[i][1];
|
||||||
if (!RegOp2MemOpTable2Addr.insert(std::make_pair((unsigned*)RegOp,
|
if (!RegOp2MemOpTable2Addr.insert(std::make_pair(RegOp,
|
||||||
std::make_pair(MemOp,0))).second)
|
std::make_pair(MemOp,0))).second)
|
||||||
assert(false && "Duplicated entries?");
|
assert(false && "Duplicated entries?");
|
||||||
// Index 0, folded load and store, no alignment requirement.
|
// Index 0, folded load and store, no alignment requirement.
|
||||||
unsigned AuxInfo = 0 | (1 << 4) | (1 << 5);
|
unsigned AuxInfo = 0 | (1 << 4) | (1 << 5);
|
||||||
if (!MemOp2RegOpTable.insert(std::make_pair((unsigned*)MemOp,
|
if (!MemOp2RegOpTable.insert(std::make_pair(MemOp,
|
||||||
std::make_pair(RegOp,
|
std::make_pair(RegOp,
|
||||||
AuxInfo))).second)
|
AuxInfo))).second)
|
||||||
assert(false && "Duplicated entries in unfolding maps?");
|
assert(false && "Duplicated entries in unfolding maps?");
|
||||||
@ -314,14 +314,14 @@ X86InstrInfo::X86InstrInfo(X86TargetMachine &tm)
|
|||||||
unsigned RegOp = OpTbl0[i][0];
|
unsigned RegOp = OpTbl0[i][0];
|
||||||
unsigned MemOp = OpTbl0[i][1];
|
unsigned MemOp = OpTbl0[i][1];
|
||||||
unsigned Align = OpTbl0[i][3];
|
unsigned Align = OpTbl0[i][3];
|
||||||
if (!RegOp2MemOpTable0.insert(std::make_pair((unsigned*)RegOp,
|
if (!RegOp2MemOpTable0.insert(std::make_pair(RegOp,
|
||||||
std::make_pair(MemOp,Align))).second)
|
std::make_pair(MemOp,Align))).second)
|
||||||
assert(false && "Duplicated entries?");
|
assert(false && "Duplicated entries?");
|
||||||
unsigned FoldedLoad = OpTbl0[i][2];
|
unsigned FoldedLoad = OpTbl0[i][2];
|
||||||
// Index 0, folded load or store.
|
// Index 0, folded load or store.
|
||||||
unsigned AuxInfo = 0 | (FoldedLoad << 4) | ((FoldedLoad^1) << 5);
|
unsigned AuxInfo = 0 | (FoldedLoad << 4) | ((FoldedLoad^1) << 5);
|
||||||
if (RegOp != X86::FsMOVAPDrr && RegOp != X86::FsMOVAPSrr)
|
if (RegOp != X86::FsMOVAPDrr && RegOp != X86::FsMOVAPSrr)
|
||||||
if (!MemOp2RegOpTable.insert(std::make_pair((unsigned*)MemOp,
|
if (!MemOp2RegOpTable.insert(std::make_pair(MemOp,
|
||||||
std::make_pair(RegOp, AuxInfo))).second)
|
std::make_pair(RegOp, AuxInfo))).second)
|
||||||
assert(false && "Duplicated entries in unfolding maps?");
|
assert(false && "Duplicated entries in unfolding maps?");
|
||||||
}
|
}
|
||||||
@ -440,13 +440,13 @@ X86InstrInfo::X86InstrInfo(X86TargetMachine &tm)
|
|||||||
unsigned RegOp = OpTbl1[i][0];
|
unsigned RegOp = OpTbl1[i][0];
|
||||||
unsigned MemOp = OpTbl1[i][1];
|
unsigned MemOp = OpTbl1[i][1];
|
||||||
unsigned Align = OpTbl1[i][2];
|
unsigned Align = OpTbl1[i][2];
|
||||||
if (!RegOp2MemOpTable1.insert(std::make_pair((unsigned*)RegOp,
|
if (!RegOp2MemOpTable1.insert(std::make_pair(RegOp,
|
||||||
std::make_pair(MemOp,Align))).second)
|
std::make_pair(MemOp,Align))).second)
|
||||||
assert(false && "Duplicated entries?");
|
assert(false && "Duplicated entries?");
|
||||||
// Index 1, folded load
|
// Index 1, folded load
|
||||||
unsigned AuxInfo = 1 | (1 << 4);
|
unsigned AuxInfo = 1 | (1 << 4);
|
||||||
if (RegOp != X86::FsMOVAPDrr && RegOp != X86::FsMOVAPSrr)
|
if (RegOp != X86::FsMOVAPDrr && RegOp != X86::FsMOVAPSrr)
|
||||||
if (!MemOp2RegOpTable.insert(std::make_pair((unsigned*)MemOp,
|
if (!MemOp2RegOpTable.insert(std::make_pair(MemOp,
|
||||||
std::make_pair(RegOp, AuxInfo))).second)
|
std::make_pair(RegOp, AuxInfo))).second)
|
||||||
assert(false && "Duplicated entries in unfolding maps?");
|
assert(false && "Duplicated entries in unfolding maps?");
|
||||||
}
|
}
|
||||||
@ -653,12 +653,12 @@ X86InstrInfo::X86InstrInfo(X86TargetMachine &tm)
|
|||||||
unsigned RegOp = OpTbl2[i][0];
|
unsigned RegOp = OpTbl2[i][0];
|
||||||
unsigned MemOp = OpTbl2[i][1];
|
unsigned MemOp = OpTbl2[i][1];
|
||||||
unsigned Align = OpTbl2[i][2];
|
unsigned Align = OpTbl2[i][2];
|
||||||
if (!RegOp2MemOpTable2.insert(std::make_pair((unsigned*)RegOp,
|
if (!RegOp2MemOpTable2.insert(std::make_pair(RegOp,
|
||||||
std::make_pair(MemOp,Align))).second)
|
std::make_pair(MemOp,Align))).second)
|
||||||
assert(false && "Duplicated entries?");
|
assert(false && "Duplicated entries?");
|
||||||
// Index 2, folded load
|
// Index 2, folded load
|
||||||
unsigned AuxInfo = 2 | (1 << 4);
|
unsigned AuxInfo = 2 | (1 << 4);
|
||||||
if (!MemOp2RegOpTable.insert(std::make_pair((unsigned*)MemOp,
|
if (!MemOp2RegOpTable.insert(std::make_pair(MemOp,
|
||||||
std::make_pair(RegOp, AuxInfo))).second)
|
std::make_pair(RegOp, AuxInfo))).second)
|
||||||
assert(false && "Duplicated entries in unfolding maps?");
|
assert(false && "Duplicated entries in unfolding maps?");
|
||||||
}
|
}
|
||||||
@ -2267,7 +2267,7 @@ X86InstrInfo::foldMemoryOperandImpl(MachineFunction &MF,
|
|||||||
MachineInstr *MI, unsigned i,
|
MachineInstr *MI, unsigned i,
|
||||||
const SmallVectorImpl<MachineOperand> &MOs,
|
const SmallVectorImpl<MachineOperand> &MOs,
|
||||||
unsigned Size, unsigned Align) const {
|
unsigned Size, unsigned Align) const {
|
||||||
const DenseMap<unsigned*, std::pair<unsigned,unsigned> > *OpcodeTablePtr=NULL;
|
const DenseMap<unsigned, std::pair<unsigned,unsigned> > *OpcodeTablePtr = 0;
|
||||||
bool isTwoAddrFold = false;
|
bool isTwoAddrFold = false;
|
||||||
unsigned NumOps = MI->getDesc().getNumOperands();
|
unsigned NumOps = MI->getDesc().getNumOperands();
|
||||||
bool isTwoAddr = NumOps > 1 &&
|
bool isTwoAddr = NumOps > 1 &&
|
||||||
@ -2305,8 +2305,8 @@ X86InstrInfo::foldMemoryOperandImpl(MachineFunction &MF,
|
|||||||
// If table selected...
|
// If table selected...
|
||||||
if (OpcodeTablePtr) {
|
if (OpcodeTablePtr) {
|
||||||
// Find the Opcode to fuse
|
// Find the Opcode to fuse
|
||||||
DenseMap<unsigned*, std::pair<unsigned,unsigned> >::const_iterator I =
|
DenseMap<unsigned, std::pair<unsigned,unsigned> >::const_iterator I =
|
||||||
OpcodeTablePtr->find((unsigned*)MI->getOpcode());
|
OpcodeTablePtr->find(MI->getOpcode());
|
||||||
if (I != OpcodeTablePtr->end()) {
|
if (I != OpcodeTablePtr->end()) {
|
||||||
unsigned Opcode = I->second.first;
|
unsigned Opcode = I->second.first;
|
||||||
unsigned MinAlign = I->second.second;
|
unsigned MinAlign = I->second.second;
|
||||||
@ -2580,7 +2580,7 @@ bool X86InstrInfo::canFoldMemoryOperand(const MachineInstr *MI,
|
|||||||
// Folding a memory location into the two-address part of a two-address
|
// Folding a memory location into the two-address part of a two-address
|
||||||
// instruction is different than folding it other places. It requires
|
// instruction is different than folding it other places. It requires
|
||||||
// replacing the *two* registers with the memory location.
|
// replacing the *two* registers with the memory location.
|
||||||
const DenseMap<unsigned*, std::pair<unsigned,unsigned> > *OpcodeTablePtr=NULL;
|
const DenseMap<unsigned, std::pair<unsigned,unsigned> > *OpcodeTablePtr = 0;
|
||||||
if (isTwoAddr && NumOps >= 2 && OpNum < 2) {
|
if (isTwoAddr && NumOps >= 2 && OpNum < 2) {
|
||||||
OpcodeTablePtr = &RegOp2MemOpTable2Addr;
|
OpcodeTablePtr = &RegOp2MemOpTable2Addr;
|
||||||
} else if (OpNum == 0) { // If operand 0
|
} else if (OpNum == 0) { // If operand 0
|
||||||
@ -2588,8 +2588,7 @@ bool X86InstrInfo::canFoldMemoryOperand(const MachineInstr *MI,
|
|||||||
case X86::MOV8r0:
|
case X86::MOV8r0:
|
||||||
case X86::MOV16r0:
|
case X86::MOV16r0:
|
||||||
case X86::MOV32r0:
|
case X86::MOV32r0:
|
||||||
case X86::MOV64r0:
|
case X86::MOV64r0: return true;
|
||||||
return true;
|
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
OpcodeTablePtr = &RegOp2MemOpTable0;
|
OpcodeTablePtr = &RegOp2MemOpTable0;
|
||||||
@ -2601,8 +2600,8 @@ bool X86InstrInfo::canFoldMemoryOperand(const MachineInstr *MI,
|
|||||||
|
|
||||||
if (OpcodeTablePtr) {
|
if (OpcodeTablePtr) {
|
||||||
// Find the Opcode to fuse
|
// Find the Opcode to fuse
|
||||||
DenseMap<unsigned*, std::pair<unsigned,unsigned> >::const_iterator I =
|
DenseMap<unsigned, std::pair<unsigned,unsigned> >::const_iterator I =
|
||||||
OpcodeTablePtr->find((unsigned*)Opc);
|
OpcodeTablePtr->find(Opc);
|
||||||
if (I != OpcodeTablePtr->end())
|
if (I != OpcodeTablePtr->end())
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2612,8 +2611,8 @@ bool X86InstrInfo::canFoldMemoryOperand(const MachineInstr *MI,
|
|||||||
bool X86InstrInfo::unfoldMemoryOperand(MachineFunction &MF, MachineInstr *MI,
|
bool X86InstrInfo::unfoldMemoryOperand(MachineFunction &MF, MachineInstr *MI,
|
||||||
unsigned Reg, bool UnfoldLoad, bool UnfoldStore,
|
unsigned Reg, bool UnfoldLoad, bool UnfoldStore,
|
||||||
SmallVectorImpl<MachineInstr*> &NewMIs) const {
|
SmallVectorImpl<MachineInstr*> &NewMIs) const {
|
||||||
DenseMap<unsigned*, std::pair<unsigned,unsigned> >::const_iterator I =
|
DenseMap<unsigned, std::pair<unsigned,unsigned> >::const_iterator I =
|
||||||
MemOp2RegOpTable.find((unsigned*)MI->getOpcode());
|
MemOp2RegOpTable.find(MI->getOpcode());
|
||||||
if (I == MemOp2RegOpTable.end())
|
if (I == MemOp2RegOpTable.end())
|
||||||
return false;
|
return false;
|
||||||
unsigned Opc = I->second.first;
|
unsigned Opc = I->second.first;
|
||||||
@ -2741,8 +2740,8 @@ X86InstrInfo::unfoldMemoryOperand(SelectionDAG &DAG, SDNode *N,
|
|||||||
if (!N->isMachineOpcode())
|
if (!N->isMachineOpcode())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
DenseMap<unsigned*, std::pair<unsigned,unsigned> >::const_iterator I =
|
DenseMap<unsigned, std::pair<unsigned,unsigned> >::const_iterator I =
|
||||||
MemOp2RegOpTable.find((unsigned*)N->getMachineOpcode());
|
MemOp2RegOpTable.find(N->getMachineOpcode());
|
||||||
if (I == MemOp2RegOpTable.end())
|
if (I == MemOp2RegOpTable.end())
|
||||||
return false;
|
return false;
|
||||||
unsigned Opc = I->second.first;
|
unsigned Opc = I->second.first;
|
||||||
@ -2842,8 +2841,8 @@ X86InstrInfo::unfoldMemoryOperand(SelectionDAG &DAG, SDNode *N,
|
|||||||
unsigned X86InstrInfo::getOpcodeAfterMemoryUnfold(unsigned Opc,
|
unsigned X86InstrInfo::getOpcodeAfterMemoryUnfold(unsigned Opc,
|
||||||
bool UnfoldLoad, bool UnfoldStore,
|
bool UnfoldLoad, bool UnfoldStore,
|
||||||
unsigned *LoadRegIndex) const {
|
unsigned *LoadRegIndex) const {
|
||||||
DenseMap<unsigned*, std::pair<unsigned,unsigned> >::const_iterator I =
|
DenseMap<unsigned, std::pair<unsigned,unsigned> >::const_iterator I =
|
||||||
MemOp2RegOpTable.find((unsigned*)Opc);
|
MemOp2RegOpTable.find(Opc);
|
||||||
if (I == MemOp2RegOpTable.end())
|
if (I == MemOp2RegOpTable.end())
|
||||||
return 0;
|
return 0;
|
||||||
bool FoldedLoad = I->second.second & (1 << 4);
|
bool FoldedLoad = I->second.second & (1 << 4);
|
||||||
|
@ -613,14 +613,14 @@ class X86InstrInfo : public TargetInstrInfoImpl {
|
|||||||
/// RegOp2MemOpTable2Addr, RegOp2MemOpTable0, RegOp2MemOpTable1,
|
/// RegOp2MemOpTable2Addr, RegOp2MemOpTable0, RegOp2MemOpTable1,
|
||||||
/// RegOp2MemOpTable2 - Load / store folding opcode maps.
|
/// RegOp2MemOpTable2 - Load / store folding opcode maps.
|
||||||
///
|
///
|
||||||
DenseMap<unsigned*, std::pair<unsigned,unsigned> > RegOp2MemOpTable2Addr;
|
DenseMap<unsigned, std::pair<unsigned,unsigned> > RegOp2MemOpTable2Addr;
|
||||||
DenseMap<unsigned*, std::pair<unsigned,unsigned> > RegOp2MemOpTable0;
|
DenseMap<unsigned, std::pair<unsigned,unsigned> > RegOp2MemOpTable0;
|
||||||
DenseMap<unsigned*, std::pair<unsigned,unsigned> > RegOp2MemOpTable1;
|
DenseMap<unsigned, std::pair<unsigned,unsigned> > RegOp2MemOpTable1;
|
||||||
DenseMap<unsigned*, std::pair<unsigned,unsigned> > RegOp2MemOpTable2;
|
DenseMap<unsigned, std::pair<unsigned,unsigned> > RegOp2MemOpTable2;
|
||||||
|
|
||||||
/// MemOp2RegOpTable - Load / store unfolding opcode map.
|
/// MemOp2RegOpTable - Load / store unfolding opcode map.
|
||||||
///
|
///
|
||||||
DenseMap<unsigned*, std::pair<unsigned, unsigned> > MemOp2RegOpTable;
|
DenseMap<unsigned, std::pair<unsigned, unsigned> > MemOp2RegOpTable;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit X86InstrInfo(X86TargetMachine &tm);
|
explicit X86InstrInfo(X86TargetMachine &tm);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user