summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2012-11-24 02:01:08 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2012-11-24 02:01:08 +0000
commit28c9ea3c13dfb8f6bb3226ba511d189135fcb140 (patch)
tree920b8cdb1cc561bc8b375aadd1d1cffaf78349a5 /include
parent4ccb49a8384d25cfeb65453da059ed1a7a00b5ed (diff)
downloadllvm-28c9ea3c13dfb8f6bb3226ba511d189135fcb140.tar.gz
llvm-28c9ea3c13dfb8f6bb3226ba511d189135fcb140.tar.bz2
llvm-28c9ea3c13dfb8f6bb3226ba511d189135fcb140.tar.xz
Refactor how MCCFIInstructions are created.
Give MCCFIInstruction a single, private constructor and add helper static methods that create each type of cfi instruction. This is is preparation for changing its representation. The representation with a pair MachineLocations older than MC and has been abused quiet a bit to support more cfi instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168532 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/MC/MCDwarf.h104
1 files changed, 88 insertions, 16 deletions
diff --git a/include/llvm/MC/MCDwarf.h b/include/llvm/MC/MCDwarf.h
index 6fa41ae67c..77b5f1c8a3 100644
--- a/include/llvm/MC/MCDwarf.h
+++ b/include/llvm/MC/MCDwarf.h
@@ -275,28 +275,100 @@ namespace llvm {
MachineLocation Destination;
MachineLocation Source;
std::vector<char> Values;
+ MCCFIInstruction(OpType Op, MCSymbol *L, const MachineLocation &D,
+ const MachineLocation &S, StringRef V) :
+ Operation(Op), Label(L), Destination(D), Source(S),
+ Values(V.begin(), V.end()) {
+ }
+
public:
- MCCFIInstruction(OpType Op, MCSymbol *L)
- : Operation(Op), Label(L) {
- assert(Op == RememberState || Op == RestoreState);
+ static MCCFIInstruction
+ createCFIOffset(MCSymbol *L, unsigned Register, int Offset) {
+ MachineLocation Dest(Register, Offset);
+ MachineLocation Source(Register, Offset);
+
+ MCCFIInstruction Ret(Move, L, Dest, Source, "");
+ return Ret;
+ }
+
+ static MCCFIInstruction
+ createDefCfaRegister(MCSymbol *L, unsigned Register) {
+ MachineLocation Dest(Register);
+ MachineLocation Source(MachineLocation::VirtualFP);
+ MCCFIInstruction Ret(Move, L, Dest, Source, "");
+ return Ret;
}
- MCCFIInstruction(OpType Op, MCSymbol *L, unsigned Register)
- : Operation(Op), Label(L), Destination(Register) {
- assert(Op == SameValue || Op == Restore || Op == Undefined);
+
+ static MCCFIInstruction createDefCfaOffset(MCSymbol *L, int Offset) {
+ MachineLocation Dest(MachineLocation::VirtualFP);
+ MachineLocation Source(MachineLocation::VirtualFP, -Offset);
+ MCCFIInstruction Ret(Move, L, Dest, Source, "");
+ return Ret;
}
- MCCFIInstruction(MCSymbol *L, const MachineLocation &D,
- const MachineLocation &S)
- : Operation(Move), Label(L), Destination(D), Source(S) {
+
+ static MCCFIInstruction
+ createDefCfa(MCSymbol *L, unsigned Register, int Offset) {
+ MachineLocation Dest(MachineLocation::VirtualFP);
+ MachineLocation Source(Register, -Offset);
+ MCCFIInstruction Ret(Move, L, Dest, Source, "");
+ return Ret;
}
- MCCFIInstruction(OpType Op, MCSymbol *L, const MachineLocation &D,
- const MachineLocation &S)
- : Operation(Op), Label(L), Destination(D), Source(S) {
- assert(Op == RelMove);
+
+ static MCCFIInstruction createUndefined(MCSymbol *L, unsigned Register) {
+ MachineLocation Dummy;
+ MachineLocation Dest(Register);
+ MCCFIInstruction Ret(Undefined, L, Dest, Dummy, "");
+ return Ret;
+ }
+
+ static MCCFIInstruction createRestore(MCSymbol *L, unsigned Register) {
+ MachineLocation Dummy;
+ MachineLocation Dest(Register);
+ MCCFIInstruction Ret(Restore, L, Dest, Dummy, "");
+ return Ret;
}
- MCCFIInstruction(OpType Op, MCSymbol *L, StringRef Vals)
- : Operation(Op), Label(L), Values(Vals.begin(), Vals.end()) {
- assert(Op == Escape);
+
+ static MCCFIInstruction createSameValue(MCSymbol *L, unsigned Register) {
+ MachineLocation Dummy;
+ MachineLocation Dest(Register);
+ MCCFIInstruction Ret(SameValue, L, Dest, Dummy, "");
+ return Ret;
+ }
+
+ static MCCFIInstruction createRestoreState(MCSymbol *L) {
+ MachineLocation Dummy;
+ MCCFIInstruction Ret(RestoreState, L, Dummy, Dummy, "");
+ return Ret;
+ }
+
+ static MCCFIInstruction createRememberState(MCSymbol *L) {
+ MachineLocation Dummy;
+ MCCFIInstruction Ret(RememberState, L, Dummy, Dummy, "");
+ return Ret;
+ }
+
+ static MCCFIInstruction
+ createRelOffset(MCSymbol *L, unsigned Register, int Offset) {
+ MachineLocation Dest(Register, Offset);
+ MachineLocation Source(Register, Offset);
+ MCCFIInstruction Ret(RelMove, L, Dest, Source, "");
+ return Ret;
+ }
+
+ static MCCFIInstruction
+ createAdjustCfaOffset(MCSymbol *L, int Adjustment) {
+ MachineLocation Dest(MachineLocation::VirtualFP);
+ MachineLocation Source(MachineLocation::VirtualFP, Adjustment);
+ MCCFIInstruction Ret(RelMove, L, Dest, Source, "");
+ return Ret;
}
+
+ static MCCFIInstruction createEscape(MCSymbol *L, StringRef Vals) {
+ MachineLocation Dummy;
+ MCCFIInstruction Ret(Escape, L, Dummy, Dummy, Vals);
+ return Ret;
+ }
+
OpType getOperation() const { return Operation; }
MCSymbol *getLabel() const { return Label; }
const MachineLocation &getDestination() const { return Destination; }