LLVM 19.0.0git
AMDGPUMCExpr.h
Go to the documentation of this file.
1//===- AMDGPUMCExpr.h - AMDGPU specific MC expression classes ---*- C++ -*-===//
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#ifndef LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUMCEXPR_H
10#define LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUMCEXPR_H
11
12#include "llvm/ADT/ArrayRef.h"
13#include "llvm/MC/MCExpr.h"
14
15namespace llvm {
16
17class Function;
18class GCNSubtarget;
19
20/// AMDGPU target specific variadic MCExpr operations.
21///
22/// Takes in a minimum of 1 argument to be used with an operation. The supported
23/// operations are:
24/// - (bitwise) or
25/// - max
26///
27/// \note If the 'or'/'max' operations are provided only a single argument, the
28/// operation will act as a no-op and simply resolve as the provided argument.
29///
31public:
40 };
41
42private:
43 VariadicKind Kind;
44 MCContext &Ctx;
45 const MCExpr **RawArgs;
47
49 MCContext &Ctx);
51
52 bool evaluateExtraSGPRs(MCValue &Res, const MCAsmLayout *Layout,
53 const MCFixup *Fixup) const;
54 bool evaluateTotalNumVGPR(MCValue &Res, const MCAsmLayout *Layout,
55 const MCFixup *Fixup) const;
56 bool evaluateAlignTo(MCValue &Res, const MCAsmLayout *Layout,
57 const MCFixup *Fixup) const;
58 bool evaluateOccupancy(MCValue &Res, const MCAsmLayout *Layout,
59 const MCFixup *Fixup) const;
60
61public:
62 static const AMDGPUVariadicMCExpr *
64
66 MCContext &Ctx) {
67 return create(VariadicKind::AGVK_Or, Args, Ctx);
68 }
69
71 MCContext &Ctx) {
72 return create(VariadicKind::AGVK_Max, Args, Ctx);
73 }
74
75 static const AMDGPUVariadicMCExpr *createExtraSGPRs(const MCExpr *VCCUsed,
76 const MCExpr *FlatScrUsed,
77 bool XNACKUsed,
78 MCContext &Ctx);
79
80 static const AMDGPUVariadicMCExpr *createTotalNumVGPR(const MCExpr *NumAGPR,
81 const MCExpr *NumVGPR,
82 MCContext &Ctx);
83
84 static const AMDGPUVariadicMCExpr *
87 }
88
89 static const AMDGPUVariadicMCExpr *createOccupancy(unsigned InitOcc,
90 const MCExpr *NumSGPRs,
91 const MCExpr *NumVGPRs,
92 const GCNSubtarget &STM,
93 MCContext &Ctx);
94
95 VariadicKind getKind() const { return Kind; }
96 const MCExpr *getSubExpr(size_t Index) const;
97
98 void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
99 bool evaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout,
100 const MCFixup *Fixup) const override;
101 void visitUsedExpr(MCStreamer &Streamer) const override;
102 MCFragment *findAssociatedFragment() const override;
103 void fixELFSymbolsInTLSFixups(MCAssembler &) const override{};
104
105 static bool classof(const MCExpr *E) {
106 return E->getKind() == MCExpr::Target;
107 }
108};
109
110} // end namespace llvm
111
112#endif // LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUMCEXPR_H
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
PowerPC TLS Dynamic Call Fixup
raw_pwrite_stream & OS
AMDGPU target specific variadic MCExpr operations.
Definition: AMDGPUMCExpr.h:30
static const AMDGPUVariadicMCExpr * create(VariadicKind Kind, ArrayRef< const MCExpr * > Args, MCContext &Ctx)
static const AMDGPUVariadicMCExpr * createMax(ArrayRef< const MCExpr * > Args, MCContext &Ctx)
Definition: AMDGPUMCExpr.h:70
static const AMDGPUVariadicMCExpr * createAlignTo(const MCExpr *Value, const MCExpr *Align, MCContext &Ctx)
Definition: AMDGPUMCExpr.h:85
static bool classof(const MCExpr *E)
Definition: AMDGPUMCExpr.h:105
static const AMDGPUVariadicMCExpr * createTotalNumVGPR(const MCExpr *NumAGPR, const MCExpr *NumVGPR, MCContext &Ctx)
static const AMDGPUVariadicMCExpr * createOccupancy(unsigned InitOcc, const MCExpr *NumSGPRs, const MCExpr *NumVGPRs, const GCNSubtarget &STM, MCContext &Ctx)
Mimics GCNSubtarget::computeOccupancy for MCExpr.
VariadicKind getKind() const
Definition: AMDGPUMCExpr.h:95
bool evaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout, const MCFixup *Fixup) const override
static const AMDGPUVariadicMCExpr * createOr(ArrayRef< const MCExpr * > Args, MCContext &Ctx)
Definition: AMDGPUMCExpr.h:65
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override
MCFragment * findAssociatedFragment() const override
const MCExpr * getSubExpr(size_t Index) const
void fixELFSymbolsInTLSFixups(MCAssembler &) const override
Definition: AMDGPUMCExpr.h:103
static const AMDGPUVariadicMCExpr * createExtraSGPRs(const MCExpr *VCCUsed, const MCExpr *FlatScrUsed, bool XNACKUsed, MCContext &Ctx)
Allow delayed MCExpr resolve of ExtraSGPRs (in case VCCUsed or FlatScrUsed are unresolvable but neede...
void visitUsedExpr(MCStreamer &Streamer) const override
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
Encapsulates the layout of an assembly file at a particular point in time.
Definition: MCAsmLayout.h:28
Context object for machine code objects.
Definition: MCContext.h:81
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
@ Target
Target specific expression.
Definition: MCExpr.h:42
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition: MCFixup.h:71
Streaming machine code generation interface.
Definition: MCStreamer.h:212
This is an extension point for target-specific MCExpr subclasses to implement.
Definition: MCExpr.h:656
This represents an "assembler immediate".
Definition: MCValue.h:36
LLVM Value Representation.
Definition: Value.h:74
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39