1 | //===--- RISCVConstantPoolValue.h - RISC-V constantpool value ---*- 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 implements the RISC-V specific constantpool value class. |
10 | // |
11 | //===----------------------------------------------------------------------===// |
12 | |
13 | #ifndef LLVM_LIB_TARGET_RISCV_RISCVCONSTANTPOOLVALUE_H |
14 | #define LLVM_LIB_TARGET_RISCV_RISCVCONSTANTPOOLVALUE_H |
15 | |
16 | #include "llvm/ADT/StringRef.h" |
17 | #include "llvm/CodeGen/MachineConstantPool.h" |
18 | #include "llvm/Support/Casting.h" |
19 | #include "llvm/Support/ErrorHandling.h" |
20 | |
21 | namespace llvm { |
22 | |
23 | class BlockAddress; |
24 | class GlobalValue; |
25 | class LLVMContext; |
26 | |
27 | /// A RISCV-specific constant pool value. |
28 | class RISCVConstantPoolValue : public MachineConstantPoolValue { |
29 | const GlobalValue *GV; |
30 | const StringRef S; |
31 | |
32 | RISCVConstantPoolValue(Type *Ty, const GlobalValue *GV); |
33 | RISCVConstantPoolValue(LLVMContext &C, StringRef S); |
34 | |
35 | private: |
36 | enum class RISCVCPKind { ExtSymbol, GlobalValue }; |
37 | RISCVCPKind Kind; |
38 | |
39 | public: |
40 | ~RISCVConstantPoolValue() = default; |
41 | |
42 | static RISCVConstantPoolValue *Create(const GlobalValue *GV); |
43 | static RISCVConstantPoolValue *Create(LLVMContext &C, StringRef S); |
44 | |
45 | bool isGlobalValue() const { return Kind == RISCVCPKind::GlobalValue; } |
46 | bool isExtSymbol() const { return Kind == RISCVCPKind::ExtSymbol; } |
47 | |
48 | const GlobalValue *getGlobalValue() const { return GV; } |
49 | StringRef getSymbol() const { return S; } |
50 | |
51 | int getExistingMachineCPValue(MachineConstantPool *CP, |
52 | Align Alignment) override; |
53 | |
54 | void addSelectionDAGCSEId(FoldingSetNodeID &ID) override; |
55 | |
56 | void print(raw_ostream &O) const override; |
57 | |
58 | bool equals(const RISCVConstantPoolValue *A) const; |
59 | }; |
60 | |
61 | } // end namespace llvm |
62 | |
63 | #endif |
64 |