aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Laskey <jlaskey@mac.com>2006-03-23 18:12:57 +0000
committerJim Laskey <jlaskey@mac.com>2006-03-23 18:12:57 +0000
commitf1d78e83356a412e525c30ac90dabf090a8cfc99 (patch)
treea677891241e018bdeffde44fe544bab3a683877c
parent4ca9757a39a1bf3bd1264a77e52db62e02cc85fb (diff)
Add support to locate local variables in frames (early version.)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26994 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Target/MRegisterInfo.h6
-rw-r--r--lib/Target/Alpha/AlphaRegisterInfo.cpp13
-rw-r--r--lib/Target/Alpha/AlphaRegisterInfo.h3
-rw-r--r--lib/Target/IA64/IA64RegisterInfo.cpp14
-rw-r--r--lib/Target/IA64/IA64RegisterInfo.h2
-rw-r--r--lib/Target/PowerPC/PPCRegisterInfo.cpp12
-rw-r--r--lib/Target/PowerPC/PPCRegisterInfo.h3
-rw-r--r--lib/Target/Sparc/SparcRegisterInfo.cpp12
-rw-r--r--lib/Target/Sparc/SparcRegisterInfo.h3
-rw-r--r--lib/Target/SparcV9/SparcV9RegisterInfo.cpp6
-rw-r--r--lib/Target/SparcV9/SparcV9RegisterInfo.h2
-rw-r--r--lib/Target/X86/X86RegisterInfo.cpp12
-rw-r--r--lib/Target/X86/X86RegisterInfo.h3
13 files changed, 91 insertions, 0 deletions
diff --git a/include/llvm/Target/MRegisterInfo.h b/include/llvm/Target/MRegisterInfo.h
index a7ce2dc111..cbd6e0fa32 100644
--- a/include/llvm/Target/MRegisterInfo.h
+++ b/include/llvm/Target/MRegisterInfo.h
@@ -26,6 +26,7 @@ namespace llvm {
class Type;
class MachineFunction;
class MachineInstr;
+class MachineLocation;
class TargetRegisterClass;
/// TargetRegisterDesc - This record contains all of the information known about
@@ -341,6 +342,11 @@ public:
virtual void emitPrologue(MachineFunction &MF) const = 0;
virtual void emitEpilogue(MachineFunction &MF,
MachineBasicBlock &MBB) const = 0;
+
+ /// getLocation - This method should return the actual location of a frame
+ /// variable given the frame index.
+ virtual void getLocation(MachineFunction &MF, unsigned Index,
+ MachineLocation &ML) const = 0;
};
// This is useful when building DenseMaps keyed on virtual registers
diff --git a/lib/Target/Alpha/AlphaRegisterInfo.cpp b/lib/Target/Alpha/AlphaRegisterInfo.cpp
index 31b20da392..f5c6dd67f5 100644
--- a/lib/Target/Alpha/AlphaRegisterInfo.cpp
+++ b/lib/Target/Alpha/AlphaRegisterInfo.cpp
@@ -21,6 +21,7 @@
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
+#include "llvm/CodeGen/MachineLocation.h"
#include "llvm/Target/TargetFrameInfo.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
@@ -353,6 +354,18 @@ void AlphaRegisterInfo::emitEpilogue(MachineFunction &MF,
}
}
+void AlphaRegisterInfo::getLocation(MachineFunction &MF, unsigned Index,
+ MachineLocation &ML) const {
+ assert(0 && "Needs to be defined for target");
+ MachineFrameInfo *MFI = MF.getFrameInfo();
+ bool FP = hasFP(MF);
+
+ // FIXME - Needs to handle register variables.
+ // FIXME - Faking that llvm number is same as gcc numbering.
+ ML.set((FP ? Alpha::R15 : Alpha::R30) - Alpha::R0,
+ MFI->getObjectOffset(Index) + MFI->getStackSize());
+}
+
#include "AlphaGenRegisterInfo.inc"
std::string AlphaRegisterInfo::getPrettyName(unsigned reg)
diff --git a/lib/Target/Alpha/AlphaRegisterInfo.h b/lib/Target/Alpha/AlphaRegisterInfo.h
index 0ad04b44ea..d07ee9006a 100644
--- a/lib/Target/Alpha/AlphaRegisterInfo.h
+++ b/lib/Target/Alpha/AlphaRegisterInfo.h
@@ -53,6 +53,9 @@ struct AlphaRegisterInfo : public AlphaGenRegisterInfo {
void emitPrologue(MachineFunction &MF) const;
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
+ void getLocation(MachineFunction &MF, unsigned Index, MachineLocation &ML) const;
+
+
static std::string getPrettyName(unsigned reg);
};
diff --git a/lib/Target/IA64/IA64RegisterInfo.cpp b/lib/Target/IA64/IA64RegisterInfo.cpp
index d612efc29d..f6d9941f8e 100644
--- a/lib/Target/IA64/IA64RegisterInfo.cpp
+++ b/lib/Target/IA64/IA64RegisterInfo.cpp
@@ -22,6 +22,7 @@
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
+#include "llvm/CodeGen/MachineLocation.h"
#include "llvm/Target/TargetFrameInfo.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
@@ -328,5 +329,18 @@ void IA64RegisterInfo::emitEpilogue(MachineFunction &MF,
}
+void IA64RegisterInfo::getLocation(MachineFunction &MF, unsigned Index,
+ MachineLocation &ML) const {
+ assert(0 && "Needs to be defined for target");
+ MachineFrameInfo *MFI = MF.getFrameInfo();
+ bool FP = hasFP(MF);
+
+ // FIXME - Needs to handle register variables.
+ // FIXME - Faking that llvm number is same as gcc numbering.
+ ML.set((FP ? IA64::r5 : IA64::r12) - IA64::r0,
+ MFI->getObjectOffset(Index) + MFI->getStackSize());
+}
+
+
#include "IA64GenRegisterInfo.inc"
diff --git a/lib/Target/IA64/IA64RegisterInfo.h b/lib/Target/IA64/IA64RegisterInfo.h
index f1b2222ce3..d33a9e6c1d 100644
--- a/lib/Target/IA64/IA64RegisterInfo.h
+++ b/lib/Target/IA64/IA64RegisterInfo.h
@@ -48,6 +48,8 @@ struct IA64RegisterInfo : public IA64GenRegisterInfo {
void emitPrologue(MachineFunction &MF) const;
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
+
+ void getLocation(MachineFunction &MF, unsigned Index, MachineLocation &ML) const;
};
} // End llvm namespace
diff --git a/lib/Target/PowerPC/PPCRegisterInfo.cpp b/lib/Target/PowerPC/PPCRegisterInfo.cpp
index 2df31e81b6..6b281bd2d8 100644
--- a/lib/Target/PowerPC/PPCRegisterInfo.cpp
+++ b/lib/Target/PowerPC/PPCRegisterInfo.cpp
@@ -21,6 +21,7 @@
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
+#include "llvm/CodeGen/MachineLocation.h"
#include "llvm/Target/TargetFrameInfo.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
@@ -446,5 +447,16 @@ void PPCRegisterInfo::emitEpilogue(MachineFunction &MF,
}
}
+void PPCRegisterInfo::getLocation(MachineFunction &MF, unsigned Index,
+ MachineLocation &ML) const {
+ MachineFrameInfo *MFI = MF.getFrameInfo();
+ bool FP = hasFP(MF);
+
+ // FIXME - Needs to handle register variables.
+ // FIXME - Faking that llvm number is same as gcc numbering.
+ ML.set((FP ? PPC::R31 : PPC::R1) - PPC::R0,
+ MFI->getObjectOffset(Index) + MFI->getStackSize());
+}
+
#include "PPCGenRegisterInfo.inc"
diff --git a/lib/Target/PowerPC/PPCRegisterInfo.h b/lib/Target/PowerPC/PPCRegisterInfo.h
index e5a94f0ff6..dce149bffc 100644
--- a/lib/Target/PowerPC/PPCRegisterInfo.h
+++ b/lib/Target/PowerPC/PPCRegisterInfo.h
@@ -55,6 +55,9 @@ public:
void emitPrologue(MachineFunction &MF) const;
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
+
+ void getLocation(MachineFunction &MF, unsigned Index,
+ MachineLocation &ML) const;
};
} // end namespace llvm
diff --git a/lib/Target/Sparc/SparcRegisterInfo.cpp b/lib/Target/Sparc/SparcRegisterInfo.cpp
index ff9c5a3ec3..21a0cd85d8 100644
--- a/lib/Target/Sparc/SparcRegisterInfo.cpp
+++ b/lib/Target/Sparc/SparcRegisterInfo.cpp
@@ -17,6 +17,7 @@
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
+#include "llvm/CodeGen/MachineLocation.h"
#include "llvm/Type.h"
#include "llvm/ADT/STLExtras.h"
#include <iostream>
@@ -199,5 +200,16 @@ void SparcRegisterInfo::emitEpilogue(MachineFunction &MF,
BuildMI(MBB, MBBI, SP::RESTORErr, 2, SP::G0).addReg(SP::G0).addReg(SP::G0);
}
+void SparcRegisterInfo::getLocation(MachineFunction &MF, unsigned Index,
+ MachineLocation &ML) const {
+ assert(0 && "Needs to be defined for target");
+ MachineFrameInfo *MFI = MF.getFrameInfo();
+
+ // FIXME - Needs to handle register variables.
+ // FIXME - Faking that llvm number is same as gcc numbering.
+ ML.set(SP::G1 - SP::G0,
+ MFI->getObjectOffset(Index) + MFI->getStackSize());
+}
+
#include "SparcGenRegisterInfo.inc"
diff --git a/lib/Target/Sparc/SparcRegisterInfo.h b/lib/Target/Sparc/SparcRegisterInfo.h
index d26e5bd376..53d3e6fdba 100644
--- a/lib/Target/Sparc/SparcRegisterInfo.h
+++ b/lib/Target/Sparc/SparcRegisterInfo.h
@@ -56,6 +56,9 @@ struct SparcRegisterInfo : public SparcGenRegisterInfo {
void emitPrologue(MachineFunction &MF) const;
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
+
+ void getLocation(MachineFunction &MF, unsigned Index,
+ MachineLocation &ML) const;
};
} // end namespace llvm
diff --git a/lib/Target/SparcV9/SparcV9RegisterInfo.cpp b/lib/Target/SparcV9/SparcV9RegisterInfo.cpp
index 0ef9d34365..db0b9fd95c 100644
--- a/lib/Target/SparcV9/SparcV9RegisterInfo.cpp
+++ b/lib/Target/SparcV9/SparcV9RegisterInfo.cpp
@@ -316,3 +316,9 @@ void SparcV9RegisterInfo::emitEpilogue(MachineFunction &MF,
MachineBasicBlock &MBB) const {
abort ();
}
+
+
+void SparcV9RegisterInfo::getLocation(MachineFunction &MF, unsigned Index,
+ MachineLocation &ML) const {
+ abort ();
+}
diff --git a/lib/Target/SparcV9/SparcV9RegisterInfo.h b/lib/Target/SparcV9/SparcV9RegisterInfo.h
index a284898f6a..4144b84dc5 100644
--- a/lib/Target/SparcV9/SparcV9RegisterInfo.h
+++ b/lib/Target/SparcV9/SparcV9RegisterInfo.h
@@ -44,6 +44,8 @@ struct SparcV9RegisterInfo : public MRegisterInfo {
void eliminateFrameIndex (MachineBasicBlock::iterator MI) const;
void emitPrologue (MachineFunction &MF) const;
void emitEpilogue (MachineFunction &MF, MachineBasicBlock &MBB) const;
+ void getLocation(MachineFunction &MF, unsigned Index,
+ MachineLocation &ML) const;
};
} // End llvm namespace
diff --git a/lib/Target/X86/X86RegisterInfo.cpp b/lib/Target/X86/X86RegisterInfo.cpp
index 66096b9845..88aa0155d1 100644
--- a/lib/Target/X86/X86RegisterInfo.cpp
+++ b/lib/Target/X86/X86RegisterInfo.cpp
@@ -21,6 +21,7 @@
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
+#include "llvm/CodeGen/MachineLocation.h"
#include "llvm/Target/TargetFrameInfo.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
@@ -685,5 +686,16 @@ void X86RegisterInfo::emitEpilogue(MachineFunction &MF,
}
}
+void X86RegisterInfo::getLocation(MachineFunction &MF, unsigned Index,
+ MachineLocation &ML) const {
+ MachineFrameInfo *MFI = MF.getFrameInfo();
+ bool FP = hasFP(MF);
+
+ // FIXME - Needs to handle register variables.
+ // FIXME - Hardcoding gcc numbering.
+ ML.set(FP ? 6 : 7,
+ MFI->getObjectOffset(Index) + MFI->getStackSize());
+}
+
#include "X86GenRegisterInfo.inc"
diff --git a/lib/Target/X86/X86RegisterInfo.h b/lib/Target/X86/X86RegisterInfo.h
index 35654ca832..db0fbbb3aa 100644
--- a/lib/Target/X86/X86RegisterInfo.h
+++ b/lib/Target/X86/X86RegisterInfo.h
@@ -62,6 +62,9 @@ struct X86RegisterInfo : public X86GenRegisterInfo {
void emitPrologue(MachineFunction &MF) const;
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
+
+ void getLocation(MachineFunction &MF, unsigned Index,
+ MachineLocation &ML) const;
};
} // End llvm namespace