Thanks to visit codestin.com
Credit goes to llvm.org

LLVM 22.0.0git
AMDGPUMCInstLower.h
Go to the documentation of this file.
1//===- AMDGPUMCInstLower.h - Lower MachineInstr to MCInst ------*- 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/// \file
10/// Header of lower AMDGPU MachineInstrs to their corresponding MCInst.
11//
12//===----------------------------------------------------------------------===//
13//
14
15#ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUMCINSTLOWER_H
16#define LLVM_LIB_TARGET_AMDGPU_AMDGPUMCINSTLOWER_H
17
18#include "AMDGPUTargetMachine.h"
19#include "llvm/IR/Constants.h"
21
22namespace llvm {
23class AsmPrinter;
24class MCContext;
25
27 MCContext &Ctx;
28 const TargetSubtargetInfo &ST;
29 const AsmPrinter ≈
30
31public:
33 const AsmPrinter &AP);
34
35 bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp) const;
36
37 /// Lower a MachineInstr to an MCInst
38 void lower(const MachineInstr *MI, MCInst &OutMI) const;
39
40 void lowerT16D16Helper(const MachineInstr *MI, MCInst &OutMI) const;
41};
42
43namespace {
44static inline const MCExpr *lowerAddrSpaceCast(const TargetMachine &TM,
45 const Constant *CV,
46 MCContext &OutContext) {
47 // TargetMachine does not support llvm-style cast. Use C++-style cast.
48 // This is safe since TM is always of type AMDGPUTargetMachine or its
49 // derived class.
50 auto &AT = static_cast<const AMDGPUTargetMachine &>(TM);
51 auto *CE = dyn_cast<ConstantExpr>(CV);
52
53 // Lower null pointers in private and local address space.
54 // Clang generates addrspacecast for null pointers in private and local
55 // address space, which needs to be lowered.
56 if (CE && CE->getOpcode() == Instruction::AddrSpaceCast) {
57 auto *Op = CE->getOperand(0);
58 auto SrcAddr = Op->getType()->getPointerAddressSpace();
59 if (Op->isNullValue() && AT.getNullPointerValue(SrcAddr) == 0) {
60 auto DstAddr = CE->getType()->getPointerAddressSpace();
61 return MCConstantExpr::create(AT.getNullPointerValue(DstAddr),
62 OutContext);
63 }
64 }
65 return nullptr;
66}
67} // namespace
68} // namespace llvm
69#endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUMCINSTLOWER_H
The AMDGPU TargetMachine interface definition for hw codegen targets.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
IRTranslator LLVM IR MI
static SDValue lowerAddrSpaceCast(SDValue Op, SelectionDAG &DAG)
bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp) const
void lowerT16D16Helper(const MachineInstr *MI, MCInst &OutMI) const
AMDGPUMCInstLower(MCContext &ctx, const TargetSubtargetInfo &ST, const AsmPrinter &AP)
void lower(const MachineInstr *MI, MCInst &OutMI) const
Lower a MachineInstr to an MCInst.
This class is intended to be used as a driving class for all asm writers.
Definition AsmPrinter.h:90
This is an important base class in LLVM.
Definition Constant.h:43
static LLVM_ABI const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Definition MCExpr.cpp:212
Context object for machine code objects.
Definition MCContext.h:83
Base class for the full range of assembler expressions which are needed for parsing.
Definition MCExpr.h:34
Instances of this class represent a single low-level machine instruction.
Definition MCInst.h:188
Instances of this class represent operands of the MCInst class.
Definition MCInst.h:40
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
Primary interface to the complete machine description for the target machine.
TargetSubtargetInfo - Generic base class for all target subtargets.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:649
DWARFExpression::Operation Op