summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/LLVMTargetMachine.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-01-04 07:36:53 +0000
committerChris Lattner <sabre@nondot.org>2008-01-04 07:36:53 +0000
commitf3edc09f9bfef53146b420e5c29ead1ee1cd969d (patch)
tree0c58075c40c5f54e387e952a527ba41059817bb2 /llvm/lib/CodeGen/LLVMTargetMachine.cpp
parentb5c1d9b7da52ee176d2fe2bf75e29c387133d49b (diff)
downloadbcm5719-llvm-f3edc09f9bfef53146b420e5c29ead1ee1cd969d.tar.gz
bcm5719-llvm-f3edc09f9bfef53146b420e5c29ead1ee1cd969d.zip
Add a really quick hack at a machine code sinking pass, enabled with --enable-sinking.
It is missing validity checks, so it is known broken. However, it is powerful enough to compile this contrived code: void test1(int C, double A, double B, double *P) { double Tmp = A*A+B*B; *P = C ? Tmp : A; } into: _test1: movsd 8(%esp), %xmm0 cmpl $0, 4(%esp) je LBB1_2 # entry LBB1_1: # entry movsd 16(%esp), %xmm1 mulsd %xmm1, %xmm1 mulsd %xmm0, %xmm0 addsd %xmm1, %xmm0 LBB1_2: # entry movl 24(%esp), %eax movsd %xmm0, (%eax) ret instead of: _test1: movsd 16(%esp), %xmm0 mulsd %xmm0, %xmm0 movsd 8(%esp), %xmm1 movapd %xmm1, %xmm2 mulsd %xmm2, %xmm2 addsd %xmm0, %xmm2 cmpl $0, 4(%esp) je LBB1_2 # entry LBB1_1: # entry movapd %xmm2, %xmm1 LBB1_2: # entry movl 24(%esp), %eax movsd %xmm1, (%eax) ret woo. llvm-svn: 45570
Diffstat (limited to 'llvm/lib/CodeGen/LLVMTargetMachine.cpp')
-rw-r--r--llvm/lib/CodeGen/LLVMTargetMachine.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/LLVMTargetMachine.cpp b/llvm/lib/CodeGen/LLVMTargetMachine.cpp
index 05284347f09..6a8e775e6b2 100644
--- a/llvm/lib/CodeGen/LLVMTargetMachine.cpp
+++ b/llvm/lib/CodeGen/LLVMTargetMachine.cpp
@@ -29,6 +29,12 @@ static cl::opt<bool> PrintISelInput("print-isel-input", cl::Hidden,
static cl::opt<bool> PrintEmittedAsm("print-emitted-asm", cl::Hidden,
cl::desc("Dump emitter generated instructions as assembly"));
+// Hidden options to help debugging
+static cl::opt<bool>
+EnableSinking("enable-sinking", cl::init(false), cl::Hidden,
+ cl::desc("Perform sinking on machine code"));
+
+
FileModel::Model
LLVMTargetMachine::addPassesToEmitFile(FunctionPassManager &PM,
std::ostream &Out,
@@ -68,6 +74,9 @@ LLVMTargetMachine::addPassesToEmitFile(FunctionPassManager &PM,
PM.add(createMachineFunctionPrinterPass(cerr));
PM.add(createMachineLICMPass());
+
+ if (EnableSinking)
+ PM.add(createMachineSinkingPass());
// Perform register allocation to convert to a concrete x86 representation
PM.add(createRegisterAllocator());
OpenPOWER on IntegriCloud