LLVM 24.0.0git
NVPTXBaseInfo.h
Go to the documentation of this file.
1//===-- NVPTXBaseInfo.h - Top-level definitions for NVPTX -------*- 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// This file contains small standalone helper functions and enum definitions for
10// the NVPTX target useful for the compiler back-end and the MC libraries.
11// As such, it deliberately does not include references to LLVM core
12// code gen types, passes, etc..
13//
14//===----------------------------------------------------------------------===//
15
16#ifndef LLVM_LIB_TARGET_NVPTX_MCTARGETDESC_NVPTXBASEINFO_H
17#define LLVM_LIB_TARGET_NVPTX_MCTARGETDESC_NVPTXBASEINFO_H
18
19#include "llvm/ADT/StringRef.h"
20#include "llvm/MC/MCRegister.h"
23namespace llvm {
24
25using namespace NVPTXAS;
26
27namespace NVPTX {
28
29// PTX virtual registers are numbered per register class. The asm printer
30// packs the class into the upper bits of the register number so that the inst
31// printer can recover the name the register was declared with.
32enum class VirtualRegisterKind : unsigned {
34 B1 = 1,
35 B16 = 2,
36 B32 = 3,
37 B64 = 4,
38 B128 = 5,
39};
40
41constexpr unsigned VirtualRegisterKindShift = 27;
42constexpr unsigned VirtualRegisterNumMask =
43 (1u << VirtualRegisterKindShift) - 1;
44
45// The packed registers are carried in MCOperands, so they must stay inside the
46// range MCRegister reserves for physical registers.
47static_assert(((static_cast<unsigned>(VirtualRegisterKind::B128)
50 "Packed virtual register does not fit in an MCRegister");
51
52/// The name prefix shared by all virtual registers of \p Kind.
54 switch (Kind) {
56 return "%p";
58 return "%rs";
60 return "%r";
62 return "%rd";
64 return "%rq";
66 break;
67 }
68 llvm_unreachable("Invalid virtual register kind");
69}
70
71} // namespace NVPTX
72
73namespace NVPTXII {
74enum {
75 // These must be kept in sync with TSFlags in NVPTXInstrFormats.td
76 // clang-format off
77 IsTexFlag = 0x40,
78 IsSuldMask = 0x180,
80 IsSustFlag = 0x200,
83 // clang-format on
84};
85} // namespace NVPTXII
86
87} // namespace llvm
88#endif
NVPTX address space definition.
static constexpr unsigned LastPhysicalReg
Definition MCRegister.h:62
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr unsigned VirtualRegisterNumMask
constexpr unsigned VirtualRegisterKindShift
StringRef getVirtualRegisterPrefix(VirtualRegisterKind Kind)
The name prefix shared by all virtual registers of Kind.
This is an optimization pass for GlobalISel generic memory operations.