PTX: Encode registers as unsigned values in the MC asm printer instead of using external symbols
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145946 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/PTX/PTXMachineFunctionInfo.h b/lib/Target/PTX/PTXMachineFunctionInfo.h
index 3b985f7..6f3b826 100644
--- a/lib/Target/PTX/PTXMachineFunctionInfo.h
+++ b/lib/Target/PTX/PTXMachineFunctionInfo.h
@@ -143,18 +143,30 @@
return UsedRegs.lookup(TRC).size();
}
+ /// getOffsetForRegister - Returns the offset of the virtual register
+ unsigned getOffsetForRegister(const TargetRegisterClass *TRC,
+ unsigned Reg) const {
+ const RegisterList &RegList = UsedRegs.lookup(TRC);
+ for (unsigned i = 0, e = RegList.size(); i != e; ++i) {
+ if (RegList[i] == Reg)
+ return i;
+ }
+ //llvm_unreachable("Unknown virtual register");
+ return 0;
+ }
+
/// getFrameSymbol - Returns the symbol name for the given FrameIndex.
const char* getFrameSymbol(int FrameIndex) {
if (FrameSymbols.count(FrameIndex)) {
return FrameSymbols.lookup(FrameIndex).c_str();
} else {
- std::string Name = "__local";
- Name += utostr(FrameIndex);
+ std::string Name = "__local";
+ Name += utostr(FrameIndex);
// The whole point of caching this name is to ensure the pointer we pass
// to any getExternalSymbol() calls will remain valid for the lifetime of
// the back-end instance. This is to work around an issue in SelectionDAG
// where symbol names are expected to be life-long strings.
- FrameSymbols[FrameIndex] = Name;
+ FrameSymbols[FrameIndex] = Name;
return FrameSymbols[FrameIndex].c_str();
}
}