From cb195f511d409817f92f13efc206edfb83020cba Mon Sep 17 00:00:00 2001 From: Anton Korobeynikov Date: Wed, 23 Apr 2008 18:18:10 +0000 Subject: [PATCH] Make stack alignment options global for all targets llvm-svn: 50157 --- llvm/include/llvm/Target/TargetOptions.h | 7 +++++++ llvm/lib/Target/TargetMachine.cpp | 14 ++++++++++++++ llvm/lib/Target/X86/X86RegisterInfo.cpp | 5 ----- llvm/lib/Target/X86/X86Subtarget.cpp | 5 +---- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/llvm/include/llvm/Target/TargetOptions.h b/llvm/include/llvm/Target/TargetOptions.h index 890263f04310..ac3a6081edc3 100644 --- a/llvm/include/llvm/Target/TargetOptions.h +++ b/llvm/include/llvm/Target/TargetOptions.h @@ -86,6 +86,13 @@ namespace llvm { /// OptimizeForSize - When this flag is set, the code generator avoids /// optimizations that increase size. extern bool OptimizeForSize; + + /// StackAlignment - Override default stack alignment for target. + extern unsigned StackAlignment; + + /// RealignStack - This flag indicates, whether stack should be automatically + /// realigned, if needed. + extern bool RealignStack; } // End llvm namespace #endif diff --git a/llvm/lib/Target/TargetMachine.cpp b/llvm/lib/Target/TargetMachine.cpp index c252368b1a3b..4b3371d92a2d 100644 --- a/llvm/lib/Target/TargetMachine.cpp +++ b/llvm/lib/Target/TargetMachine.cpp @@ -36,6 +36,8 @@ namespace llvm { CodeModel::Model CMModel; bool PerformTailCallOpt; bool OptimizeForSize; + bool RealignStack; + unsigned StackAlignment; } namespace { cl::opt PrintCode("print-machineinstrs", @@ -135,6 +137,18 @@ namespace { cl::desc("Optimize for size."), cl::location(OptimizeForSize), cl::init(false)); + + cl::opt + EnableRealignStack("realign-stack", + cl::desc("Realign stack if needed"), + cl::location(RealignStack), + cl::init(true)); + + cl::opt + OverrideStackAlignment("stack-alignment", + cl::desc("Override default stack alignment"), + cl::location(StackAlignment), + cl::init(0)); } //--------------------------------------------------------------------------- diff --git a/llvm/lib/Target/X86/X86RegisterInfo.cpp b/llvm/lib/Target/X86/X86RegisterInfo.cpp index f923aef60d13..563093bdec90 100644 --- a/llvm/lib/Target/X86/X86RegisterInfo.cpp +++ b/llvm/lib/Target/X86/X86RegisterInfo.cpp @@ -29,7 +29,6 @@ #include "llvm/CodeGen/MachineLocation.h" #include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/CodeGen/MachineRegisterInfo.h" -#include "llvm/Support/CommandLine.h" #include "llvm/Target/TargetAsmInfo.h" #include "llvm/Target/TargetFrameInfo.h" #include "llvm/Target/TargetInstrInfo.h" @@ -39,10 +38,6 @@ #include "llvm/ADT/STLExtras.h" using namespace llvm; -static cl::opt -RealignStack("realign-stack", cl::init(true), - cl::desc("Realign stack if needed")); - X86RegisterInfo::X86RegisterInfo(X86TargetMachine &tm, const TargetInstrInfo &tii) : X86GenRegisterInfo(X86::ADJCALLSTACKDOWN, X86::ADJCALLSTACKUP), diff --git a/llvm/lib/Target/X86/X86Subtarget.cpp b/llvm/lib/Target/X86/X86Subtarget.cpp index 71b5cb31f575..e0f350c5a1cf 100644 --- a/llvm/lib/Target/X86/X86Subtarget.cpp +++ b/llvm/lib/Target/X86/X86Subtarget.cpp @@ -16,6 +16,7 @@ #include "llvm/Module.h" #include "llvm/Support/CommandLine.h" #include "llvm/Target/TargetMachine.h" +#include "llvm/Target/TargetOptions.h" using namespace llvm; cl::opt @@ -26,10 +27,6 @@ AsmWriterFlavor("x86-asm-syntax", cl::init(X86Subtarget::Unset), clEnumValN(X86Subtarget::Intel, "intel", " Emit Intel-style assembly"), clEnumValEnd)); -cl::opt -StackAlignment("stack-alignment", cl::init(0), - cl::desc("Override default stack alignment")); - /// True if accessing the GV requires an extra load. For Windows, dllimported /// symbols are indirect, loading the value at address GV rather then the