llvm.org GIT mirror llvm / 13131e6
Cleanup and document MachineLocation. Clarify documentation and API to make the difference between register and register-indirect addressed locations more explicit. Put in a comment to point out that with the current implementation we cannot specify a register-indirect location with offset 0 (a breg 0 in DWARF). No functionality change intended. rdar://problem/13658587 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180641 91177308-0d34-0410-b5e6-96231b3b80d8 Adrian Prantl 7 years ago
3 changed file(s) with 15 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
88 // The MachineLocation class is used to represent a simple location in a machine
99 // frame. Locations will be one of two forms; a register or an address formed
1010 // from a base address plus an offset. Register indirection can be specified by
11 // using an offset of zero.
11 // explicitly passing an offset to the constructor.
1212 //
1313 // The MachineMove class is used to represent abstract move operations in the
1414 // prolog/epilog of a compiled function. A collection of these objects can be
3636 };
3737 MachineLocation()
3838 : IsRegister(false), Register(0), Offset(0) {}
39 /// Create a direct register location.
3940 explicit MachineLocation(unsigned R)
4041 : IsRegister(true), Register(R), Offset(0) {}
42 /// Create a register-indirect location with an offset.
4143 MachineLocation(unsigned R, int O)
4244 : IsRegister(false), Register(R), Offset(O) {}
4345
4749 }
4850
4951 // Accessors
52 bool isIndirect() const { return !IsRegister; }
5053 bool isReg() const { return IsRegister; }
5154 unsigned getReg() const { return Register; }
5255 int getOffset() const { return Offset; }
5356 void setIsRegister(bool Is) { IsRegister = Is; }
5457 void setRegister(unsigned R) { Register = R; }
5558 void setOffset(int O) { Offset = O; }
59 /// Make this location a direct register location.
5660 void set(unsigned R) {
5761 IsRegister = true;
5862 Register = R;
5963 Offset = 0;
6064 }
65 /// Make this location a register-indirect+offset location.
6166 void set(unsigned R, int O) {
6267 IsRegister = false;
6368 Register = R;
812812 // caller might be in the middle of an dwarf expression. We should
813813 // probably assert that Reg >= 0 once debug info generation is more mature.
814814
815 if (int Offset = MLoc.getOffset()) {
815 if (MLoc.isIndirect()) {
816816 if (Reg < 32) {
817817 OutStreamer.AddComment(
818818 dwarf::OperationEncodingString(dwarf::DW_OP_breg0 + Reg));
823823 OutStreamer.AddComment(Twine(Reg));
824824 EmitULEB128(Reg);
825825 }
826 EmitSLEB128(Offset);
826 EmitSLEB128(MLoc.getOffset());
827827 } else {
828828 if (Reg < 32) {
829829 OutStreamer.AddComment(
11301130 }
11311131 if (MI->getOperand(0).isReg() && MI->getOperand(1).isImm()) {
11321132 MachineLocation MLoc;
1133 MLoc.set(MI->getOperand(0).getReg(), MI->getOperand(1).getImm());
1133 // TODO: Currently an offset of 0 in a DBG_VALUE means
1134 // we need to generate a direct register value.
1135 // There is no way to specify an indirect value with offset 0.
1136 if (MI->getOperand(1).getImm() == 0)
1137 MLoc.set(MI->getOperand(0).getReg());
1138 else
1139 MLoc.set(MI->getOperand(0).getReg(), MI->getOperand(1).getImm());
11341140 return DotDebugLocEntry(FLabel, SLabel, MLoc, Var);
11351141 }
11361142 if (MI->getOperand(0).isImm())