zpu: wip - add pass to convert registers to stack slots
[llvm/zpu.git] / lib / Target / ZPU / ZPUStackSlot.cpp
blob3754742a888036bd1fc81115f891940439b90e65
1 //===-- ZPUFloatingPoint.cpp - Floating point Reg -> Stack converter ------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the pass which converts floating point instructions from
11 // pseudo registers into register stack instructions. This pass uses live
12 // variable information to indicate where the FPn registers are used and their
13 // lifetimes.
15 // The x87 hardware tracks liveness of the stack registers, so it is necessary
16 // to implement exact liveness tracking between basic blocks. The CFG edges are
17 // partitioned into bundles where the same FP registers must be live in
18 // identical stack positions. Instructions are inserted at the end of each basic
19 // block to rearrange the live registers to match the outgoing bundle.
21 // This approach avoids splitting critical edges at the potential cost of more
22 // live register shuffling instructions when critical edges are present.
24 //===----------------------------------------------------------------------===//
26 #define DEBUG_TYPE "ZPU-codegen"
27 #include "ZPU.h"
28 #include "ZPUInstrInfo.h"
29 #include "llvm/ADT/DepthFirstIterator.h"
30 #include "llvm/ADT/DenseMap.h"
31 #include "llvm/ADT/SmallPtrSet.h"
32 #include "llvm/ADT/SmallVector.h"
33 #include "llvm/ADT/Statistic.h"
34 #include "llvm/ADT/STLExtras.h"
35 #include "llvm/CodeGen/MachineFunctionPass.h"
36 #include "llvm/CodeGen/MachineInstrBuilder.h"
37 #include "llvm/CodeGen/MachineRegisterInfo.h"
38 #include "llvm/CodeGen/Passes.h"
39 #include "llvm/Support/Debug.h"
40 #include "llvm/Support/ErrorHandling.h"
41 #include "llvm/Support/raw_ostream.h"
42 #include "llvm/Target/TargetInstrInfo.h"
43 #include "llvm/Target/TargetMachine.h"
44 #include <algorithm>
45 using namespace llvm;
48 namespace {
49 struct ZPUStackSlot : public MachineFunctionPass {
50 static char ID;
51 ZPUStackSlot() : MachineFunctionPass(ID) {
54 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
55 AU.setPreservesCFG();
56 AU.addPreservedID(MachineLoopInfoID);
57 AU.addPreservedID(MachineDominatorsID);
58 MachineFunctionPass::getAnalysisUsage(AU);
61 virtual bool runOnMachineFunction(MachineFunction &MF);
63 virtual const char *getPassName() const { return "ZPU FP Stackifier"; }
65 private:
66 const TargetInstrInfo *TII; // Machine instruction info.
69 char ZPUStackSlot::ID = 0;
72 FunctionPass *llvm::createZPUStackSlotPass() { return new ZPUStackSlot(); }
75 /// runOnMachineFunction - Loop over all of the basic blocks, transforming FP
76 /// register references into FP stack references.
77 ///
78 bool ZPUStackSlot::runOnMachineFunction(MachineFunction &MF) {
79 return false;