2012-12-11 22:25:42 +01:00
|
|
|
//===-- AMDGPUTargetMachine.h - AMDGPU TargetMachine Interface --*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
/// \file
|
|
|
|
/// \brief The AMDGPU TargetMachine interface definition for hw codgen targets.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2016-03-11 09:00:27 +01:00
|
|
|
#ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUTARGETMACHINE_H
|
|
|
|
#define LLVM_LIB_TARGET_AMDGPU_AMDGPUTARGETMACHINE_H
|
2012-12-11 22:25:42 +01:00
|
|
|
|
2014-06-23 20:00:31 +02:00
|
|
|
#include "AMDGPUIntrinsicInfo.h"
|
2012-12-11 22:25:42 +01:00
|
|
|
#include "AMDGPUSubtarget.h"
|
2016-12-09 23:06:55 +01:00
|
|
|
#include "llvm/ADT/Optional.h"
|
|
|
|
#include "llvm/ADT/StringMap.h"
|
|
|
|
#include "llvm/ADT/StringRef.h"
|
|
|
|
#include "llvm/Analysis/TargetTransformInfo.h"
|
|
|
|
#include "llvm/Support/CodeGen.h"
|
|
|
|
#include "llvm/Target/TargetMachine.h"
|
|
|
|
#include <memory>
|
2012-12-11 22:25:42 +01:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2015-01-06 19:00:21 +01:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// AMDGPU Target Machine (R600+)
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2012-12-11 22:25:42 +01:00
|
|
|
class AMDGPUTargetMachine : public LLVMTargetMachine {
|
2015-01-06 19:00:21 +01:00
|
|
|
protected:
|
2015-09-25 23:41:28 +02:00
|
|
|
std::unique_ptr<TargetLoweringObjectFile> TLOF;
|
2014-08-04 19:37:43 +02:00
|
|
|
AMDGPUIntrinsicInfo IntrinsicInfo;
|
2017-03-27 16:04:01 +02:00
|
|
|
AMDGPUAS AS;
|
2012-12-11 22:25:42 +01:00
|
|
|
|
2016-06-27 22:48:03 +02:00
|
|
|
StringRef getGPUName(const Function &F) const;
|
|
|
|
StringRef getFeatureString(const Function &F) const;
|
|
|
|
|
2012-12-11 22:25:42 +01:00
|
|
|
public:
|
2016-02-05 19:29:17 +01:00
|
|
|
AMDGPUTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
|
2016-05-19 00:04:49 +02:00
|
|
|
StringRef FS, TargetOptions Options,
|
|
|
|
Optional<Reloc::Model> RM, CodeModel::Model CM,
|
|
|
|
CodeGenOpt::Level OL);
|
2016-12-09 23:06:55 +01:00
|
|
|
~AMDGPUTargetMachine() override;
|
2015-03-12 01:07:24 +01:00
|
|
|
|
2016-06-24 08:30:11 +02:00
|
|
|
const AMDGPUSubtarget *getSubtargetImpl() const;
|
2016-07-22 19:01:25 +02:00
|
|
|
const AMDGPUSubtarget *getSubtargetImpl(const Function &) const override = 0;
|
2016-06-24 08:30:11 +02:00
|
|
|
|
2014-09-03 13:41:21 +02:00
|
|
|
const AMDGPUIntrinsicInfo *getIntrinsicInfo() const override {
|
|
|
|
return &IntrinsicInfo;
|
|
|
|
}
|
2015-02-01 14:20:00 +01:00
|
|
|
TargetIRAnalysis getTargetIRAnalysis() override;
|
2015-01-31 12:17:59 +01:00
|
|
|
|
2014-11-13 10:26:31 +01:00
|
|
|
TargetLoweringObjectFile *getObjFileLowering() const override {
|
2015-09-25 23:41:28 +02:00
|
|
|
return TLOF.get();
|
2014-11-13 10:26:31 +01:00
|
|
|
}
|
2017-03-27 16:04:01 +02:00
|
|
|
AMDGPUAS getAMDGPUAS() const {
|
|
|
|
return AS;
|
|
|
|
}
|
2017-01-26 17:49:08 +01:00
|
|
|
|
|
|
|
void adjustPassManager(PassManagerBuilder &) override;
|
2017-02-07 01:43:21 +01:00
|
|
|
/// Get the integer value of a null pointer in the given address space.
|
|
|
|
uint64_t getNullPointerValue(unsigned AddrSpace) const {
|
2017-03-27 16:04:01 +02:00
|
|
|
if (AddrSpace == AS.LOCAL_ADDRESS || AddrSpace == AS.REGION_ADDRESS)
|
2017-02-07 01:43:21 +01:00
|
|
|
return -1;
|
2017-03-27 16:04:01 +02:00
|
|
|
return 0;
|
2017-02-07 01:43:21 +01:00
|
|
|
}
|
|
|
|
|
2012-12-11 22:25:42 +01:00
|
|
|
};
|
|
|
|
|
2015-02-11 18:11:50 +01:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// R600 Target Machine (R600 -> Cayman)
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2016-03-11 09:00:27 +01:00
|
|
|
class R600TargetMachine final : public AMDGPUTargetMachine {
|
2016-06-24 08:30:11 +02:00
|
|
|
private:
|
2016-06-27 22:48:03 +02:00
|
|
|
mutable StringMap<std::unique_ptr<R600Subtarget>> SubtargetMap;
|
2015-02-11 18:11:50 +01:00
|
|
|
|
|
|
|
public:
|
2016-02-05 19:29:17 +01:00
|
|
|
R600TargetMachine(const Target &T, const Triple &TT, StringRef CPU,
|
2016-05-19 00:04:49 +02:00
|
|
|
StringRef FS, TargetOptions Options,
|
|
|
|
Optional<Reloc::Model> RM, CodeModel::Model CM,
|
|
|
|
CodeGenOpt::Level OL);
|
2015-02-11 18:11:51 +01:00
|
|
|
|
|
|
|
TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
|
2016-06-24 08:30:11 +02:00
|
|
|
|
2016-06-27 22:48:03 +02:00
|
|
|
const R600Subtarget *getSubtargetImpl(const Function &) const override;
|
2015-02-11 18:11:50 +01:00
|
|
|
};
|
|
|
|
|
2015-01-06 19:00:21 +01:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// GCN Target Machine (SI+)
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2016-03-11 09:00:27 +01:00
|
|
|
class GCNTargetMachine final : public AMDGPUTargetMachine {
|
2016-06-24 08:30:11 +02:00
|
|
|
private:
|
2016-06-27 22:48:03 +02:00
|
|
|
mutable StringMap<std::unique_ptr<SISubtarget>> SubtargetMap;
|
2015-01-06 19:00:21 +01:00
|
|
|
|
|
|
|
public:
|
2016-02-05 19:29:17 +01:00
|
|
|
GCNTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
|
2016-05-19 00:04:49 +02:00
|
|
|
StringRef FS, TargetOptions Options,
|
|
|
|
Optional<Reloc::Model> RM, CodeModel::Model CM,
|
|
|
|
CodeGenOpt::Level OL);
|
2015-02-11 18:11:51 +01:00
|
|
|
|
|
|
|
TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
|
2016-06-24 08:30:11 +02:00
|
|
|
|
2016-06-27 22:48:03 +02:00
|
|
|
const SISubtarget *getSubtargetImpl(const Function &) const override;
|
2015-01-06 19:00:21 +01:00
|
|
|
};
|
|
|
|
|
2016-12-09 23:06:55 +01:00
|
|
|
} // end namespace llvm
|
2012-12-11 22:25:42 +01:00
|
|
|
|
2016-12-09 23:06:55 +01:00
|
|
|
#endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUTARGETMACHINE_H
|