Skip to content

Commit 6d5e780

Browse files
committed
Resolve merge conflict (10/03/16)
2 parents 0c4f641 + 5c1bdf9 commit 6d5e780

29 files changed

+444
-134
lines changed

lib/Target/AArch64/AArch64RegisterBankInfo.cpp

Lines changed: 44 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,47 @@ static bool isPreISelGenericFloatingPointOpcode(unsigned Opc) {
291291
return false;
292292
}
293293

294+
RegisterBankInfo::InstructionMapping
295+
AArch64RegisterBankInfo::getSameKindOfOperandsMapping(const MachineInstr &MI) {
296+
const unsigned Opc = MI.getOpcode();
297+
const MachineFunction &MF = *MI.getParent()->getParent();
298+
const MachineRegisterInfo &MRI = MF.getRegInfo();
299+
300+
unsigned NumOperands = MI.getNumOperands();
301+
assert(NumOperands <= 3 &&
302+
"This code is for instructions with 3 or less operands");
303+
304+
LLT Ty = MRI.getType(MI.getOperand(0).getReg());
305+
unsigned Size = Ty.getSizeInBits();
306+
bool IsFPR = Ty.isVector() || isPreISelGenericFloatingPointOpcode(Opc);
307+
308+
#ifndef NDEBUG
309+
// Make sure all the operands are using similar size and type.
310+
// Should probably be checked by the machine verifier.
311+
// This code won't catch cases where the number of lanes is
312+
// different between the operands.
313+
// If we want to go to that level of details, it is probably
314+
// best to check that the types are the same, period.
315+
// Currently, we just check that the register banks are the same
316+
// for each types.
317+
for (unsigned Idx = 1; Idx != NumOperands; ++Idx) {
318+
LLT OpTy = MRI.getType(MI.getOperand(Idx).getReg());
319+
assert(AArch64::getRegBankBaseIdxOffset(OpTy.getSizeInBits()) ==
320+
AArch64::getRegBankBaseIdxOffset(Size) &&
321+
"Operand has incompatible size");
322+
bool OpIsFPR = OpTy.isVector() || isPreISelGenericFloatingPointOpcode(Opc);
323+
(void)OpIsFPR;
324+
assert(IsFPR == OpIsFPR && "Operand has incompatible type");
325+
}
326+
#endif // End NDEBUG.
327+
328+
AArch64::PartialMappingIdx RBIdx =
329+
IsFPR ? AArch64::FirstFPR : AArch64::FirstGPR;
330+
331+
return InstructionMapping{DefaultMappingID, 1,
332+
AArch64::getValueMapping(RBIdx, Size), NumOperands};
333+
}
334+
294335
RegisterBankInfo::InstructionMapping
295336
AArch64RegisterBankInfo::getInstrMapping(const MachineInstr &MI) const {
296337
const unsigned Opc = MI.getOpcode();
@@ -305,7 +346,6 @@ AArch64RegisterBankInfo::getInstrMapping(const MachineInstr &MI) const {
305346
return Mapping;
306347
}
307348

308-
unsigned NumOperands = MI.getNumOperands();
309349
switch (Opc) {
310350
// G_{F|S|U}REM are not listed because they are not legal.
311351
// Arithmetic ops.
@@ -327,35 +367,13 @@ AArch64RegisterBankInfo::getInstrMapping(const MachineInstr &MI) const {
327367
case TargetOpcode::G_FADD:
328368
case TargetOpcode::G_FSUB:
329369
case TargetOpcode::G_FMUL:
330-
case TargetOpcode::G_FDIV:{
331-
assert(NumOperands == 3 && "This code is for 3-operands instructions");
332-
333-
LLT Ty = MRI.getType(MI.getOperand(0).getReg());
334-
unsigned Size = Ty.getSizeInBits();
335-
// Make sure all the operands are using similar size.
336-
// Should probably be checked by the machine verifier.
337-
assert(AArch64::getRegBankBaseIdxOffset(
338-
MRI.getType(MI.getOperand(1).getReg()).getSizeInBits()) ==
339-
AArch64::getRegBankBaseIdxOffset(Size) &&
340-
"Operand 1 has incompatible size");
341-
assert(AArch64::getRegBankBaseIdxOffset(
342-
MRI.getType(MI.getOperand(2).getReg()).getSizeInBits()) ==
343-
AArch64::getRegBankBaseIdxOffset(Size) &&
344-
"Operand 2 has incompatible size");
345-
346-
bool IsFPR = Ty.isVector() || isPreISelGenericFloatingPointOpcode(Opc);
347-
348-
AArch64::PartialMappingIdx RBIdx =
349-
IsFPR ? AArch64::FirstFPR : AArch64::FirstGPR;
350-
351-
return InstructionMapping{DefaultMappingID, 1,
352-
AArch64::getValueMapping(RBIdx, Size),
353-
NumOperands};
354-
}
370+
case TargetOpcode::G_FDIV:
371+
return getSameKindOfOperandsMapping(MI);
355372
default:
356373
break;
357374
}
358375

376+
unsigned NumOperands = MI.getNumOperands();
359377
RegisterBankInfo::InstructionMapping Mapping =
360378
InstructionMapping{DefaultMappingID, 1, nullptr, NumOperands};
361379

lib/Target/AArch64/AArch64RegisterBankInfo.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ class AArch64RegisterBankInfo final : public RegisterBankInfo {
3838
/// See RegisterBankInfo::applyMapping.
3939
void applyMappingImpl(const OperandsMapper &OpdMapper) const override;
4040

41+
/// Get an instruction mapping where all the operands map to
42+
/// the same register bank and have similar size.
43+
///
44+
/// \pre MI.getNumOperands() <= 3
45+
///
46+
/// \return An InstructionMappings with a statically allocated
47+
/// OperandsMapping.
48+
static InstructionMapping
49+
getSameKindOfOperandsMapping(const MachineInstr &MI);
50+
4151
public:
4252
AArch64RegisterBankInfo(const TargetRegisterInfo &TRI);
4353
/// Get the cost of a copy from \p B to \p A, or put differently,

lib/Target/AArch64/AArch64Subtarget.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ UseAddressTopByteIgnored("aarch64-use-tbi", cl::desc("Assume that top byte of "
3636
"an address is ignored"), cl::init(false), cl::Hidden);
3737

3838
AArch64Subtarget &
39-
AArch64Subtarget::initializeSubtargetDependencies(StringRef FS) {
39+
AArch64Subtarget::initializeSubtargetDependencies(StringRef FS,
40+
StringRef CPUString) {
4041
// Determine default and user-specified characteristics
4142

4243
if (CPUString.empty())
@@ -90,8 +91,8 @@ AArch64Subtarget::AArch64Subtarget(const Triple &TT, const std::string &CPU,
9091
const std::string &FS,
9192
const TargetMachine &TM, bool LittleEndian)
9293
: AArch64GenSubtargetInfo(TT, CPU, FS), ReserveX18(TT.isOSDarwin()),
93-
IsLittle(LittleEndian), CPUString(CPU), TargetTriple(TT), FrameLowering(),
94-
InstrInfo(initializeSubtargetDependencies(FS)), TSInfo(),
94+
IsLittle(LittleEndian), TargetTriple(TT), FrameLowering(),
95+
InstrInfo(initializeSubtargetDependencies(FS, CPU)), TSInfo(),
9596
TLInfo(TM, *this), GISel() {}
9697

9798
const CallLowering *AArch64Subtarget::getCallLowering() const {

lib/Target/AArch64/AArch64Subtarget.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,6 @@ class AArch64Subtarget final : public AArch64GenSubtargetInfo {
9797

9898
bool IsLittle;
9999

100-
/// CPUString - String name of used CPU.
101-
std::string CPUString;
102-
103100
/// TargetTriple - What processor and OS we're targeting.
104101
Triple TargetTriple;
105102

@@ -116,7 +113,8 @@ class AArch64Subtarget final : public AArch64GenSubtargetInfo {
116113
/// initializeSubtargetDependencies - Initializes using CPUString and the
117114
/// passed in feature string so that we can use initializer lists for
118115
/// subtarget initialization.
119-
AArch64Subtarget &initializeSubtargetDependencies(StringRef FS);
116+
AArch64Subtarget &initializeSubtargetDependencies(StringRef FS,
117+
StringRef CPUString);
120118

121119
/// Initialize properties based on the selected processor family.
122120
void initializeProperties();

lib/Target/AMDGPU/AMDGPU.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#define LLVM_LIB_TARGET_AMDGPU_AMDGPU_H
1313

1414
#include "llvm/IR/Instructions.h"
15+
#include "llvm/Target/TargetMachine.h"
1516

1617
namespace llvm {
1718

@@ -89,7 +90,8 @@ void initializeAMDGPUPromoteAllocaPass(PassRegistry&);
8990
extern char &AMDGPUPromoteAllocaID;
9091

9192
Pass *createAMDGPUStructurizeCFGPass();
92-
FunctionPass *createAMDGPUISelDag(TargetMachine &tm);
93+
FunctionPass *createAMDGPUISelDag(TargetMachine &TM,
94+
CodeGenOpt::Level OptLevel);
9395
ModulePass *createAMDGPUAlwaysInlinePass();
9496
ModulePass *createAMDGPUOpenCLImageTypeLoweringPass();
9597
FunctionPass *createAMDGPUAnnotateUniformValues();

lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ bool AMDGPUCodeGenPrepare::isI32Ty(const Type *T) const {
172172
}
173173

174174
bool AMDGPUCodeGenPrepare::isSigned(const BinaryOperator &I) const {
175-
return I.getOpcode() == Instruction::SDiv ||
176-
I.getOpcode() == Instruction::SRem;
175+
return I.getOpcode() == Instruction::AShr ||
176+
I.getOpcode() == Instruction::SDiv || I.getOpcode() == Instruction::SRem;
177177
}
178178

179179
bool AMDGPUCodeGenPrepare::isSigned(const SelectInst &I) const {

lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ class AMDGPUDAGToDAGISel : public SelectionDAGISel {
4646
const AMDGPUSubtarget *Subtarget;
4747

4848
public:
49-
AMDGPUDAGToDAGISel(TargetMachine &TM);
49+
explicit AMDGPUDAGToDAGISel(TargetMachine &TM, CodeGenOpt::Level OptLevel)
50+
: SelectionDAGISel(TM, OptLevel) {}
51+
5052
virtual ~AMDGPUDAGToDAGISel();
5153
bool runOnMachineFunction(MachineFunction &MF) override;
5254
void Select(SDNode *N) override;
@@ -149,13 +151,11 @@ class AMDGPUDAGToDAGISel : public SelectionDAGISel {
149151

150152
/// \brief This pass converts a legalized DAG into a AMDGPU-specific
151153
// DAG, ready for instruction scheduling.
152-
FunctionPass *llvm::createAMDGPUISelDag(TargetMachine &TM) {
153-
return new AMDGPUDAGToDAGISel(TM);
154+
FunctionPass *llvm::createAMDGPUISelDag(TargetMachine &TM,
155+
CodeGenOpt::Level OptLevel) {
156+
return new AMDGPUDAGToDAGISel(TM, OptLevel);
154157
}
155158

156-
AMDGPUDAGToDAGISel::AMDGPUDAGToDAGISel(TargetMachine &TM)
157-
: SelectionDAGISel(TM) {}
158-
159159
bool AMDGPUDAGToDAGISel::runOnMachineFunction(MachineFunction &MF) {
160160
Subtarget = &MF.getSubtarget<AMDGPUSubtarget>();
161161
return SelectionDAGISel::runOnMachineFunction(MF);

lib/Target/AMDGPU/AMDGPUTargetMachine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ bool AMDGPUPassConfig::addPreISel() {
441441
}
442442

443443
bool AMDGPUPassConfig::addInstSelector() {
444-
addPass(createAMDGPUISelDag(getAMDGPUTargetMachine()));
444+
addPass(createAMDGPUISelDag(getAMDGPUTargetMachine(), getOptLevel()));
445445
return false;
446446
}
447447

lib/Target/Hexagon/RDFGraph.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -213,18 +213,21 @@ raw_ostream &operator<< (raw_ostream &OS,
213213
const MachineInstr &MI = *P.Obj.Addr->getCode();
214214
unsigned Opc = MI.getOpcode();
215215
OS << Print<NodeId>(P.Obj.Id, P.G) << ": " << P.G.getTII().getName(Opc);
216-
// Print the target for calls (for readability).
217-
if (MI.getDesc().isCall()) {
218-
MachineInstr::const_mop_iterator Fn =
216+
// Print the target for calls and branches (for readability).
217+
if (MI.isCall() || MI.isBranch()) {
218+
MachineInstr::const_mop_iterator T =
219219
find_if(MI.operands(),
220220
[] (const MachineOperand &Op) -> bool {
221-
return Op.isGlobal() || Op.isSymbol();
221+
return Op.isMBB() || Op.isGlobal() || Op.isSymbol();
222222
});
223-
if (Fn != MI.operands_end()) {
224-
if (Fn->isGlobal())
225-
OS << ' ' << Fn->getGlobal()->getName();
226-
else if (Fn->isSymbol())
227-
OS << ' ' << Fn->getSymbolName();
223+
if (T != MI.operands_end()) {
224+
OS << ' ';
225+
if (T->isMBB())
226+
OS << "BB#" << T->getMBB()->getNumber();
227+
else if (T->isGlobal())
228+
OS << T->getGlobal()->getName();
229+
else if (T->isSymbol())
230+
OS << T->getSymbolName();
228231
}
229232
}
230233
OS << " [" << PrintListV<RefNode*>(P.Obj.Addr->members(P.G), P.G) << ']';
@@ -263,8 +266,8 @@ raw_ostream &operator<< (raw_ostream &OS,
263266
}
264267
};
265268

266-
OS << Print<NodeId>(P.Obj.Id, P.G) << ": === BB#" << BB->getNumber()
267-
<< " === preds(" << NP << "): ";
269+
OS << Print<NodeId>(P.Obj.Id, P.G) << ": --- BB#" << BB->getNumber()
270+
<< " --- preds(" << NP << "): ";
268271
for (auto I : BB->predecessors())
269272
Ns.push_back(I->getNumber());
270273
PrintBBs(Ns);

lib/Target/Hexagon/RDFLiveness.cpp

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ void Liveness::computePhiInfo() {
530530
RegisterSet UpReached;
531531
for (const std::pair<RegisterRef,NodeSet> &T : RUM) {
532532
RegisterRef R = T.first;
533-
if (!isRestrictedToRef(PA, UA, R))
533+
if (UA.Addr->getFlags() & NodeAttrs::Shadow)
534534
R = getRestrictedRegRef(UA);
535535
if (!MidDefs.hasCoverOf(R))
536536
UpReached.insert(R);
@@ -648,7 +648,7 @@ void Liveness::computeLiveIns() {
648648
auto &LOX = PhiLOX[PrA.Addr->getCode()];
649649
for (auto R : RUs) {
650650
RegisterRef RR = R.first;
651-
if (!isRestrictedToRef(PA, UA, RR))
651+
if (UA.Addr->getFlags() & NodeAttrs::Shadow)
652652
RR = getRestrictedRegRef(UA);
653653
// The restricted ref may be different from the ref that was
654654
// accessed in the "real use". This means that this phi use
@@ -770,29 +770,6 @@ void Liveness::resetKills(MachineBasicBlock *B) {
770770
}
771771

772772

773-
// For shadows, determine if RR is aliased to a reaching def of any other
774-
// shadow associated with RA. The register ref on RA will be "larger" than
775-
// each individual reaching def, and to determine the data-flow between defs
776-
// and uses of RR it may be necessary to visit all shadows. If RR is not
777-
// aliased to the reaching def of any other shadow, then visiting only RA
778-
// is sufficient. In that sense, the data flow of RR would be restricted to
779-
// the reference RA.
780-
// For non-shadows, this function returns "true".
781-
bool Liveness::isRestrictedToRef(NodeAddr<InstrNode*> IA, NodeAddr<RefNode*> RA,
782-
RegisterRef RR) const {
783-
NodeId Start = RA.Id;
784-
for (NodeAddr<RefNode*> TA = DFG.getNextShadow(IA, RA);
785-
TA.Id != 0 && TA.Id != Start; TA = DFG.getNextShadow(IA, TA)) {
786-
NodeId RD = TA.Addr->getReachingDef();
787-
if (RD == 0)
788-
continue;
789-
if (DFG.alias(RR, DFG.addr<DefNode*>(RD).Addr->getRegRef()))
790-
return false;
791-
}
792-
return true;
793-
}
794-
795-
796773
RegisterRef Liveness::getRestrictedRegRef(NodeAddr<RefNode*> RA) const {
797774
assert(DFG.IsRef<NodeAttrs::Use>(RA));
798775
if (RA.Addr->getFlags() & NodeAttrs::Shadow) {
@@ -850,12 +827,13 @@ void Liveness::traverse(MachineBasicBlock *B, RefMap &LiveIn) {
850827
}
851828

852829
if (Trace) {
853-
dbgs() << LLVM_FUNCTION_NAME << " in BB#" << B->getNumber()
854-
<< " after recursion into";
830+
dbgs() << "\n-- BB#" << B->getNumber() << ": " << LLVM_FUNCTION_NAME
831+
<< " after recursion into: {";
855832
for (auto I : *N)
856833
dbgs() << ' ' << I->getBlock()->getNumber();
857-
dbgs() << "\n LiveIn: " << Print<RefMap>(LiveIn, DFG);
858-
dbgs() << "\n Local: " << Print<RegisterSet>(LiveMap[B], DFG) << '\n';
834+
dbgs() << " }\n";
835+
dbgs() << " LiveIn: " << Print<RefMap>(LiveIn, DFG) << '\n';
836+
dbgs() << " Local: " << Print<RegisterSet>(LiveMap[B], DFG) << '\n';
859837
}
860838

861839
// Add phi uses that are live on exit from this block.

0 commit comments

Comments
 (0)