Use %ull here.
[llvm/stm8.git] / lib / Target / PTX / PTXMFInfoExtract.cpp
blobc5e1910072395ae7c44c666408c3ecc6a84e4d49
1 //===-- PTXMFInfoExtract.cpp - Extract PTX machine function info ----------===//
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 an information extractor for PTX machine functions.
12 //===----------------------------------------------------------------------===//
14 #define DEBUG_TYPE "ptx-mf-info-extract"
16 #include "PTX.h"
17 #include "PTXTargetMachine.h"
18 #include "PTXMachineFunctionInfo.h"
19 #include "llvm/CodeGen/MachineFunctionPass.h"
20 #include "llvm/CodeGen/MachineRegisterInfo.h"
21 #include "llvm/Support/Debug.h"
22 #include "llvm/Support/ErrorHandling.h"
23 #include "llvm/Support/raw_ostream.h"
25 // NOTE: PTXMFInfoExtract must after register allocation!
27 namespace llvm {
28 /// PTXMFInfoExtract - PTX specific code to extract of PTX machine
29 /// function information for PTXAsmPrinter
30 ///
31 class PTXMFInfoExtract : public MachineFunctionPass {
32 private:
33 static char ID;
35 public:
36 PTXMFInfoExtract(PTXTargetMachine &TM, CodeGenOpt::Level OptLevel)
37 : MachineFunctionPass(ID) {}
39 virtual bool runOnMachineFunction(MachineFunction &MF);
41 virtual const char *getPassName() const {
42 return "PTX Machine Function Info Extractor";
44 }; // class PTXMFInfoExtract
45 } // namespace llvm
47 using namespace llvm;
49 char PTXMFInfoExtract::ID = 0;
51 bool PTXMFInfoExtract::runOnMachineFunction(MachineFunction &MF) {
52 PTXMachineFunctionInfo *MFI = MF.getInfo<PTXMachineFunctionInfo>();
53 MachineRegisterInfo &MRI = MF.getRegInfo();
55 DEBUG(dbgs() << "******** PTX FUNCTION LOCAL VAR REG DEF ********\n");
57 unsigned retreg = MFI->retReg();
59 DEBUG(dbgs()
60 << "PTX::NoRegister == " << PTX::NoRegister << "\n"
61 << "PTX::NUM_TARGET_REGS == " << PTX::NUM_TARGET_REGS << "\n");
63 DEBUG(for (unsigned reg = PTX::NoRegister + 1;
64 reg < PTX::NUM_TARGET_REGS; ++reg)
65 if (MRI.isPhysRegUsed(reg))
66 dbgs() << "Used Reg: " << reg << "\n";);
68 // FIXME: This is a slow linear scanning
69 for (unsigned reg = PTX::NoRegister + 1; reg < PTX::NUM_TARGET_REGS; ++reg)
70 if (MRI.isPhysRegUsed(reg) &&
71 reg != retreg &&
72 (MFI->isKernel() || !MFI->isArgReg(reg)))
73 MFI->addLocalVarReg(reg);
75 // Notify MachineFunctionInfo that I've done adding local var reg
76 MFI->doneAddLocalVar();
78 DEBUG(dbgs() << "Return Reg: " << retreg << "\n");
80 DEBUG(for (PTXMachineFunctionInfo::reg_iterator
81 i = MFI->argRegBegin(), e = MFI->argRegEnd();
82 i != e; ++i)
83 dbgs() << "Arg Reg: " << *i << "\n";);
85 DEBUG(for (PTXMachineFunctionInfo::reg_iterator
86 i = MFI->localVarRegBegin(), e = MFI->localVarRegEnd();
87 i != e; ++i)
88 dbgs() << "Local Var Reg: " << *i << "\n";);
90 return false;
93 FunctionPass *llvm::createPTXMFInfoExtract(PTXTargetMachine &TM,
94 CodeGenOpt::Level OptLevel) {
95 return new PTXMFInfoExtract(TM, OptLevel);