Align function starts to target-specific bundle alignment.
BUG=none
R=stichnot@chromium.org
Review URL: https://codereview.chromium.org/515993002
diff --git a/src/IceCfg.cpp b/src/IceCfg.cpp
index 6fe7eb0..d699ef5 100644
--- a/src/IceCfg.cpp
+++ b/src/IceCfg.cpp
@@ -314,6 +314,13 @@
Str << "\t.globl\t" << MangledName << "\n";
Str << "\t.type\t" << MangledName << ",@function\n";
}
+ Str << "\t.p2align " << getTarget()->getBundleAlignLog2Bytes() << ",0x";
+ llvm::ArrayRef<uint8_t> Pad = getTarget()->getNonExecBundlePadding();
+ for (llvm::ArrayRef<uint8_t>::iterator I = Pad.begin(), E = Pad.end();
+ I != E; ++I) {
+ Str.write_hex(*I);
+ }
+ Str << "\n";
for (NodeList::const_iterator I = Nodes.begin(), E = Nodes.end(); I != E;
++I) {
(*I)->emit(this);
diff --git a/src/IceDefs.h b/src/IceDefs.h
index d156a60..5cd1282 100644
--- a/src/IceDefs.h
+++ b/src/IceDefs.h
@@ -27,6 +27,7 @@
#include <string>
#include <vector>
+#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/SmallBitVector.h"
#include "llvm/ADT/STLExtras.h"
diff --git a/src/IceTargetLowering.h b/src/IceTargetLowering.h
index 6bf1424..a3410eb 100644
--- a/src/IceTargetLowering.h
+++ b/src/IceTargetLowering.h
@@ -137,6 +137,8 @@
virtual bool hasFramePointer() const { return false; }
virtual SizeT getFrameOrStackReg() const = 0;
virtual size_t typeWidthInBytesOnStack(Type Ty) const = 0;
+ virtual SizeT getBundleAlignLog2Bytes() const = 0;
+ virtual llvm::ArrayRef<uint8_t> getNonExecBundlePadding() const = 0;
bool hasComputedFrame() const { return HasComputedFrame; }
bool shouldDoNopInsertion() const;
int32_t getStackAdjustment() const { return StackAdjustment; }
diff --git a/src/IceTargetLoweringX8632.h b/src/IceTargetLoweringX8632.h
index 499790e..6f8ee02 100644
--- a/src/IceTargetLoweringX8632.h
+++ b/src/IceTargetLoweringX8632.h
@@ -45,6 +45,11 @@
// i8, and i16 are rounded up to 4 bytes.
return (typeWidthInBytes(Ty) + 3) & ~3;
}
+ virtual SizeT getBundleAlignLog2Bytes() const { return 5; }
+ virtual llvm::ArrayRef<uint8_t> getNonExecBundlePadding() const {
+ static const uint8_t Padding[] = { 0xF4 };
+ return llvm::ArrayRef<uint8_t>(Padding, 1);
+ }
virtual void emitVariable(const Variable *Var, const Cfg *Func) const;
virtual void lowerArguments();
virtual void addProlog(CfgNode *Node);