mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-29 10:32:47 +00:00
fd8978b021
- Allow i16, i32, i64, float, and double types, using the native .u16, .u32, .u64, .f32, and .f64 PTX types. - Allow loading/storing of all primitive types. - Allow primitive types to be passed as parameters. - Allow selection of PTX Version and Shader Model as sub-target attributes. - Merge integer/floating-point test cases for load/store. - Use .u32 instead of .s32 to conform to output from NVidia nvcc compiler. Patch by Justin Holewinski git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126824 91177308-0d34-0410-b5e6-96231b3b80d8
97 lines
3.1 KiB
C++
97 lines
3.1 KiB
C++
//===-- PTXMFInfoExtract.cpp - Extract PTX machine function info ----------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file defines an information extractor for PTX machine functions.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#define DEBUG_TYPE "ptx-mf-info-extract"
|
|
|
|
#include "PTX.h"
|
|
#include "PTXTargetMachine.h"
|
|
#include "PTXMachineFunctionInfo.h"
|
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
|
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
|
#include "llvm/Support/Debug.h"
|
|
#include "llvm/Support/ErrorHandling.h"
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
// NOTE: PTXMFInfoExtract must after register allocation!
|
|
|
|
namespace llvm {
|
|
/// PTXMFInfoExtract - PTX specific code to extract of PTX machine
|
|
/// function information for PTXAsmPrinter
|
|
///
|
|
class PTXMFInfoExtract : public MachineFunctionPass {
|
|
private:
|
|
static char ID;
|
|
|
|
public:
|
|
PTXMFInfoExtract(PTXTargetMachine &TM, CodeGenOpt::Level OptLevel)
|
|
: MachineFunctionPass(ID) {}
|
|
|
|
virtual bool runOnMachineFunction(MachineFunction &MF);
|
|
|
|
virtual const char *getPassName() const {
|
|
return "PTX Machine Function Info Extractor";
|
|
}
|
|
}; // class PTXMFInfoExtract
|
|
} // namespace llvm
|
|
|
|
using namespace llvm;
|
|
|
|
char PTXMFInfoExtract::ID = 0;
|
|
|
|
bool PTXMFInfoExtract::runOnMachineFunction(MachineFunction &MF) {
|
|
PTXMachineFunctionInfo *MFI = MF.getInfo<PTXMachineFunctionInfo>();
|
|
MachineRegisterInfo &MRI = MF.getRegInfo();
|
|
|
|
DEBUG(dbgs() << "******** PTX FUNCTION LOCAL VAR REG DEF ********\n");
|
|
|
|
unsigned retreg = MFI->retReg();
|
|
|
|
DEBUG(dbgs()
|
|
<< "PTX::NoRegister == " << PTX::NoRegister << "\n"
|
|
<< "PTX::NUM_TARGET_REGS == " << PTX::NUM_TARGET_REGS << "\n");
|
|
|
|
DEBUG(for (unsigned reg = PTX::NoRegister + 1;
|
|
reg < PTX::NUM_TARGET_REGS; ++reg)
|
|
if (MRI.isPhysRegUsed(reg))
|
|
dbgs() << "Used Reg: " << reg << "\n";);
|
|
|
|
// FIXME: This is a slow linear scanning
|
|
for (unsigned reg = PTX::NoRegister + 1; reg < PTX::NUM_TARGET_REGS; ++reg)
|
|
if (MRI.isPhysRegUsed(reg) &&
|
|
reg != retreg &&
|
|
(MFI->isKernel() || !MFI->isArgReg(reg)))
|
|
MFI->addLocalVarReg(reg);
|
|
|
|
// Notify MachineFunctionInfo that I've done adding local var reg
|
|
MFI->doneAddLocalVar();
|
|
|
|
DEBUG(dbgs() << "Return Reg: " << retreg << "\n");
|
|
|
|
DEBUG(for (PTXMachineFunctionInfo::reg_iterator
|
|
i = MFI->argRegBegin(), e = MFI->argRegEnd();
|
|
i != e; ++i)
|
|
dbgs() << "Arg Reg: " << *i << "\n";);
|
|
|
|
DEBUG(for (PTXMachineFunctionInfo::reg_iterator
|
|
i = MFI->localVarRegBegin(), e = MFI->localVarRegEnd();
|
|
i != e; ++i)
|
|
dbgs() << "Local Var Reg: " << *i << "\n";);
|
|
|
|
return false;
|
|
}
|
|
|
|
FunctionPass *llvm::createPTXMFInfoExtract(PTXTargetMachine &TM,
|
|
CodeGenOpt::Level OptLevel) {
|
|
return new PTXMFInfoExtract(TM, OptLevel);
|
|
}
|