LLVM  14.0.0git
RISCVMatInt.h
Go to the documentation of this file.
1 //===- RISCVMatInt.h - Immediate materialisation ---------------*- 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_RISCV_MATINT_H
10 #define LLVM_LIB_TARGET_RISCV_MATINT_H
11 
12 #include "llvm/ADT/SmallVector.h"
14 #include <cstdint>
15 
16 namespace llvm {
17 class APInt;
18 class MCSubtargetInfo;
19 
20 namespace RISCVMatInt {
21 struct Inst {
22  unsigned Opc;
23  int64_t Imm;
24 
25  Inst(unsigned Opc, int64_t Imm) : Opc(Opc), Imm(Imm) {}
26 };
28 
29 // Helper to generate an instruction sequence that will materialise the given
30 // immediate value into a register. A sequence of instructions represented by a
31 // simple struct is produced rather than directly emitting the instructions in
32 // order to allow this helper to be used from both the MC layer and during
33 // instruction selection.
34 InstSeq generateInstSeq(int64_t Val, const FeatureBitset &ActiveFeatures);
35 
36 // Helper to estimate the number of instructions required to materialise the
37 // given immediate value into a register. This estimate does not account for
38 // `Val` possibly fitting into an immediate, and so may over-estimate.
39 //
40 // This will attempt to produce instructions to materialise `Val` as an
41 // `Size`-bit immediate.
42 //
43 // If CompressionCost is true it will use a different cost calculation if RVC is
44 // enabled. This should be used to compare two different sequences to determine
45 // which is more compressible.
46 int getIntMatCost(const APInt &Val, unsigned Size,
47  const FeatureBitset &ActiveFeatures,
48  bool CompressionCost = false);
49 } // namespace RISCVMatInt
50 } // namespace llvm
51 #endif
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
llvm::RISCVMatInt::Inst
Definition: RISCVMatInt.h:21
llvm::RISCVMatInt::getIntMatCost
int getIntMatCost(const APInt &Val, unsigned Size, const FeatureBitset &ActiveFeatures, bool CompressionCost)
Definition: RISCVMatInt.cpp:318
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
llvm::RISCVMatInt::Inst::Opc
unsigned Opc
Definition: RISCVMatInt.h:22
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1168
llvm::RISCVMatInt::generateInstSeq
InstSeq generateInstSeq(int64_t Val, const FeatureBitset &ActiveFeatures)
Definition: RISCVMatInt.cpp:146
llvm::FeatureBitset
Container class for subtarget features.
Definition: SubtargetFeature.h:40
SubtargetFeature.h
llvm::RISCVMatInt::Inst::Imm
int64_t Imm
Definition: RISCVMatInt.h:23
llvm::APInt
Class for arbitrary precision integers.
Definition: APInt.h:75
llvm::RISCVMatInt::Inst::Inst
Inst(unsigned Opc, int64_t Imm)
Definition: RISCVMatInt.h:25
SmallVector.h