2012-05-04 20:18:50 +00:00
|
|
|
//===-- NVPTX.h - Top-level interface for NVPTX representation --*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file contains the entry points for global functions defined in
|
|
|
|
// the LLVM NVPTX back-end.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_TARGET_NVPTX_H
|
|
|
|
#define LLVM_TARGET_NVPTX_H
|
|
|
|
|
2012-12-04 07:12:27 +00:00
|
|
|
#include "MCTargetDesc/NVPTXBaseInfo.h"
|
2013-05-20 16:42:16 +00:00
|
|
|
#include "llvm/ADT/StringMap.h"
|
2013-01-02 11:36:10 +00:00
|
|
|
#include "llvm/IR/Module.h"
|
|
|
|
#include "llvm/IR/Value.h"
|
2012-05-04 20:18:50 +00:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
|
|
|
#include "llvm/Target/TargetMachine.h"
|
2012-06-05 19:06:13 +00:00
|
|
|
#include <cassert>
|
|
|
|
#include <iosfwd>
|
2012-05-04 20:18:50 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
class NVPTXTargetMachine;
|
|
|
|
class FunctionPass;
|
|
|
|
class formatted_raw_ostream;
|
|
|
|
|
|
|
|
namespace NVPTXCC {
|
|
|
|
enum CondCodes {
|
|
|
|
EQ,
|
|
|
|
NE,
|
|
|
|
LT,
|
|
|
|
LE,
|
|
|
|
GT,
|
|
|
|
GE
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
inline static const char *NVPTXCondCodeToString(NVPTXCC::CondCodes CC) {
|
|
|
|
switch (CC) {
|
2013-03-30 14:29:21 +00:00
|
|
|
case NVPTXCC::NE:
|
|
|
|
return "ne";
|
|
|
|
case NVPTXCC::EQ:
|
|
|
|
return "eq";
|
|
|
|
case NVPTXCC::LT:
|
|
|
|
return "lt";
|
|
|
|
case NVPTXCC::LE:
|
|
|
|
return "le";
|
|
|
|
case NVPTXCC::GT:
|
|
|
|
return "gt";
|
|
|
|
case NVPTXCC::GE:
|
|
|
|
return "ge";
|
2012-05-04 20:18:50 +00:00
|
|
|
}
|
2012-05-04 21:35:49 +00:00
|
|
|
llvm_unreachable("Unknown condition code");
|
2012-05-04 20:18:50 +00:00
|
|
|
}
|
|
|
|
|
2013-03-30 14:29:21 +00:00
|
|
|
FunctionPass *
|
|
|
|
createNVPTXISelDag(NVPTXTargetMachine &TM, llvm::CodeGenOpt::Level OptLevel);
|
2012-05-04 20:18:50 +00:00
|
|
|
FunctionPass *createLowerStructArgsPass(NVPTXTargetMachine &);
|
|
|
|
FunctionPass *createNVPTXReMatPass(NVPTXTargetMachine &);
|
|
|
|
FunctionPass *createNVPTXReMatBlockPass(NVPTXTargetMachine &);
|
2013-05-20 12:13:32 +00:00
|
|
|
ModulePass *createGenericToNVVMPass();
|
2013-05-20 16:42:16 +00:00
|
|
|
ModulePass *createNVVMReflectPass();
|
|
|
|
ModulePass *createNVVMReflectPass(const StringMap<int>& Mapping);
|
2012-05-04 20:18:50 +00:00
|
|
|
|
|
|
|
bool isImageOrSamplerVal(const Value *, const Module *);
|
|
|
|
|
|
|
|
extern Target TheNVPTXTarget32;
|
|
|
|
extern Target TheNVPTXTarget64;
|
|
|
|
|
2013-03-30 14:29:21 +00:00
|
|
|
namespace NVPTX {
|
2012-05-04 20:18:50 +00:00
|
|
|
enum DrvInterface {
|
|
|
|
NVCL,
|
|
|
|
CUDA,
|
|
|
|
TEST
|
|
|
|
};
|
|
|
|
|
|
|
|
// A field inside TSFlags needs a shift and a mask. The usage is
|
|
|
|
// always as follows :
|
|
|
|
// ((TSFlags & fieldMask) >> fieldShift)
|
|
|
|
// The enum keeps the mask, the shift, and all valid values of the
|
|
|
|
// field in one place.
|
|
|
|
enum VecInstType {
|
|
|
|
VecInstTypeShift = 0,
|
|
|
|
VecInstTypeMask = 0xF,
|
|
|
|
|
|
|
|
VecNOP = 0,
|
|
|
|
VecLoad = 1,
|
|
|
|
VecStore = 2,
|
|
|
|
VecBuild = 3,
|
|
|
|
VecShuffle = 4,
|
|
|
|
VecExtract = 5,
|
|
|
|
VecInsert = 6,
|
|
|
|
VecDest = 7,
|
|
|
|
VecOther = 15
|
|
|
|
};
|
|
|
|
|
|
|
|
enum SimpleMove {
|
|
|
|
SimpleMoveMask = 0x10,
|
|
|
|
SimpleMoveShift = 4
|
|
|
|
};
|
|
|
|
enum LoadStore {
|
|
|
|
isLoadMask = 0x20,
|
|
|
|
isLoadShift = 5,
|
|
|
|
isStoreMask = 0x40,
|
|
|
|
isStoreShift = 6
|
|
|
|
};
|
|
|
|
|
|
|
|
namespace PTXLdStInstCode {
|
2013-03-30 14:29:21 +00:00
|
|
|
enum AddressSpace {
|
2012-05-04 20:18:50 +00:00
|
|
|
GENERIC = 0,
|
|
|
|
GLOBAL = 1,
|
|
|
|
CONSTANT = 2,
|
|
|
|
SHARED = 3,
|
|
|
|
PARAM = 4,
|
|
|
|
LOCAL = 5
|
|
|
|
};
|
|
|
|
enum FromType {
|
|
|
|
Unsigned = 0,
|
|
|
|
Signed,
|
|
|
|
Float
|
|
|
|
};
|
|
|
|
enum VecType {
|
|
|
|
Scalar = 1,
|
|
|
|
V2 = 2,
|
|
|
|
V4 = 4
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} // end namespace llvm;
|
|
|
|
|
|
|
|
// Defines symbolic names for NVPTX registers. This defines a mapping from
|
|
|
|
// register name to register number.
|
|
|
|
#define GET_REGINFO_ENUM
|
|
|
|
#include "NVPTXGenRegisterInfo.inc"
|
|
|
|
|
|
|
|
// Defines symbolic names for the NVPTX instructions.
|
|
|
|
#define GET_INSTRINFO_ENUM
|
|
|
|
#include "NVPTXGenInstrInfo.inc"
|
|
|
|
|
|
|
|
#endif
|