aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorVikram S. Adve <vadve@cs.uiuc.edu>2001-11-15 15:22:26 +0000
committerVikram S. Adve <vadve@cs.uiuc.edu>2001-11-15 15:22:26 +0000
commit7c47c7201d762c24bc6140b6e5a2ac511aec5cb1 (patch)
treeb7b1e734c1c2edceaf2e98c548334d16bfa9ced1 /lib/CodeGen
parentf6dfca13955b1eef40745c2b18b81c0ae7f46d41 (diff)
Modify AllocateLocalVar method to take a size argument.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1318 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/MachineInstr.cpp32
1 files changed, 29 insertions, 3 deletions
diff --git a/lib/CodeGen/MachineInstr.cpp b/lib/CodeGen/MachineInstr.cpp
index 5993daf65a..383bd2a32d 100644
--- a/lib/CodeGen/MachineInstr.cpp
+++ b/lib/CodeGen/MachineInstr.cpp
@@ -16,6 +16,7 @@
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/Target/MachineFrameInfo.h"
#include "llvm/Target/MachineRegInfo.h"
+#include "llvm/Target/MachineCacheInfo.h"
#include "llvm/Method.h"
#include "llvm/iOther.h"
#include "llvm/Instruction.h"
@@ -192,6 +193,24 @@ operator<<(ostream &os, const MachineOperand &mop)
return os;
}
+// Align data larger than one L1 cache line on L1 cache line boundaries.
+// Align all smaller data on the next higher 2^x boundary (4, 8, ...).
+//
+// THIS FUNCTION HAS BEEN COPIED FROM EMITASSEMBLY.CPP AND
+// SHOULD BE USED DIRECTLY THERE
+//
+inline unsigned int
+SizeToAlignment(unsigned int size, const TargetMachine& target)
+{
+ unsigned short cacheLineSize = target.getCacheInfo().getCacheLineSize(1);
+ if (size > (unsigned) cacheLineSize / 2)
+ return cacheLineSize;
+ else
+ for (unsigned sz=1; /*no condition*/; sz *= 2)
+ if (sz >= size)
+ return sz;
+}
+
static unsigned int
ComputeMaxOptionalArgsSize(const TargetMachine& target, const Method* method)
{
@@ -248,7 +267,8 @@ MachineCodeForMethod::MachineCodeForMethod(const Method* _M,
int
MachineCodeForMethod::allocateLocalVar(const TargetMachine& target,
- const Value* val)
+ const Value* val,
+ unsigned int size)
{
// Check if we've allocated a stack slot for this value already
//
@@ -258,9 +278,15 @@ MachineCodeForMethod::allocateLocalVar(const TargetMachine& target,
bool growUp;
int firstOffset =target.getFrameInfo().getFirstAutomaticVarOffset(*this,
growUp);
- unsigned int size = target.findOptimalStorageSize(val->getType());
- unsigned char align = target.DataLayout.getTypeAlignment(val->getType());
+ unsigned char align;
+ if (size == 0)
+ {
+ size = target.findOptimalStorageSize(val->getType());
+ // align = target.DataLayout.getTypeAlignment(val->getType());
+ }
+ align = SizeToAlignment(size, target);
+
offset = getAutomaticVarsSize();
if (! growUp)
offset += size;