brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · b2ce57a Raw
64 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8//9// This file implements the RISC-V specific constantpool value class.10//11//===----------------------------------------------------------------------===//12 13#ifndef LLVM_LIB_TARGET_RISCV_RISCVCONSTANTPOOLVALUE_H14#define LLVM_LIB_TARGET_RISCV_RISCVCONSTANTPOOLVALUE_H15 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 21namespace llvm {22 23class BlockAddress;24class GlobalValue;25class LLVMContext;26 27/// A RISCV-specific constant pool value.28class 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 35private:36  enum class RISCVCPKind { ExtSymbol, GlobalValue };37  RISCVCPKind Kind;38 39public:40  ~RISCVConstantPoolValue() override = 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 llvm62 63#endif64