LLVM 24.0.0git
PISATargetMachine.cpp
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8///
9/// \file
10/// This file implements the PISA target machine.
11///
12//===----------------------------------------------------------------------===//
13
14#include "PISATargetMachine.h"
15#include "PISA.h"
20#include "llvm/IR/Function.h"
23
24using namespace llvm;
25
26// NOLINTNEXTLINE(readability-identifier-naming)
31
32static Reloc::Model getEffectiveRelocModel(std::optional<Reloc::Model> RM) {
33 if (!RM)
34 return Reloc::PIC_;
35 return *RM;
36}
37
39 StringRef CPU, StringRef FS,
41 std::optional<Reloc::Model> RM,
42 std::optional<CodeModel::Model> CM,
43 CodeGenOptLevel OL, bool JIT)
44 : CodeGenTargetMachineImpl(T, TT, CPU, FS, Options,
46 getEffectiveCodeModel(CM, CodeModel::Small), OL),
47 TLOF(std::make_unique<TargetLoweringObjectFileELF>()),
48 Subtarget(TT, CPU.str(), FS.str(), *this) {
50 setGlobalISel(true);
51 setFastISel(false);
52 setO0WantsFastISel(false);
54}
55
56const PISASubtarget *
58 Attribute CPUAttr = F.getFnAttribute("target-cpu");
59 Attribute FSAttr = F.getFnAttribute("target-features");
60
61 StringRef CPU =
62 CPUAttr.isValid() ? CPUAttr.getValueAsString() : getTargetCPU();
63 StringRef FS =
64 FSAttr.isValid() ? FSAttr.getValueAsString() : getTargetFeatureString();
65
67 Key.append(FS);
68
69 auto &I = SubtargetMap[Key];
70 if (!I)
71 I = std::make_unique<PISASubtarget>(TargetTriple, CPU.str(), FS.str(),
72 *this);
73 return I.get();
74}
75
76namespace {
77class PISAPassConfig : public TargetPassConfig {
78public:
79 PISAPassConfig(PISATargetMachine &TM, PassManagerBase &PM)
80 : TargetPassConfig(TM, PM) {}
81
82 PISATargetMachine &getPISATargetMachine() const {
84 }
85};
86} // namespace
87
89 return new PISAPassConfig(*this, PM);
90}
static Reloc::Model getEffectiveRelocModel()
#define LLVM_EXTERNAL_VISIBILITY
Definition Compiler.h:132
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
#define T
This file declares the PISA target registration interface.
LLVM_EXTERNAL_VISIBILITY void LLVMInitializePISATarget()
This file declares the PISA target machine.
This file declares the top-level interfaces for the PISA target.
const GCNTargetMachine & getTM(const GCNSubtarget *STI)
This file defines the SmallString class.
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
Target-Independent Code Generator Pass Configuration Options pass.
Functions, function parameters, and return types can have attributes to indicate how they should be t...
Definition Attributes.h:106
LLVM_ABI StringRef getValueAsString() const
Return the attribute's value as a string.
bool isValid() const
Return true if the attribute is any kind of attribute.
Definition Attributes.h:260
CodeGenTargetMachineImpl(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Reloc::Model RM, CodeModel::Model CM, CodeGenOptLevel OL)
TargetPassConfig * createPassConfig(PassManagerBase &PM) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
PISATargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional< Reloc::Model > RM, std::optional< CodeModel::Model > CM, CodeGenOptLevel OL, bool JIT)
const PISASubtarget * getSubtargetImpl() const =delete
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition SmallString.h:28
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Triple TargetTriple
Triple string, CPU name, and target feature strings the TargetMachine instance is created with.
void setFastISel(bool Enable)
StringRef getTargetFeatureString() const
StringRef getTargetCPU() const
void setRequiresStructuredCFG(bool Value)
void setGlobalISel(bool Enable)
TargetOptions Options
void setO0WantsFastISel(bool Enable)
Target-Independent Code Generator Pass Configuration Options.
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:48
PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...
This is an optimization pass for GlobalISel generic memory operations.
Target & getThePISATarget()
static Reloc::Model getEffectiveRelocModel(std::optional< Reloc::Model > RM)
CodeModel::Model getEffectiveCodeModel(std::optional< CodeModel::Model > CM, CodeModel::Model Default)
Helper method for getting the code model, returning Default if CM does not have a value.
CodeGenOptLevel
Code generation optimization level.
Definition CodeGen.h:280
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:879
RegisterTargetMachine - Helper template for registering a target machine implementation,...