Path: blob/main/contrib/llvm-project/llvm/utils/TableGen/Common/VarLenCodeEmitterGen.h
35290 views
//===- VarLenCodeEmitterGen.h - CEG for variable-length insts ---*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file declare the CodeEmitterGen component for variable-length9// instructions. See the .cpp file for more details.10//11//===----------------------------------------------------------------------===//1213#ifndef LLVM_UTILS_TABLEGEN_VARLENCODEEMITTERGEN_H14#define LLVM_UTILS_TABLEGEN_VARLENCODEEMITTERGEN_H1516#include "llvm/TableGen/Record.h"1718namespace llvm {1920struct EncodingSegment {21unsigned BitWidth;22const Init *Value;23StringRef CustomEncoder = "";24StringRef CustomDecoder = "";25};2627class VarLenInst {28const RecordVal *TheDef;29size_t NumBits;3031// Set if any of the segment is not fixed value.32bool HasDynamicSegment;3334SmallVector<EncodingSegment, 4> Segments;3536void buildRec(const DagInit *DI);3738public:39VarLenInst() : TheDef(nullptr), NumBits(0U), HasDynamicSegment(false) {}4041explicit VarLenInst(const DagInit *DI, const RecordVal *TheDef);4243/// Number of bits44size_t size() const { return NumBits; }4546using const_iterator = decltype(Segments)::const_iterator;4748const_iterator begin() const { return Segments.begin(); }49const_iterator end() const { return Segments.end(); }50size_t getNumSegments() const { return Segments.size(); }5152bool isFixedValueOnly() const { return !HasDynamicSegment; }53};5455void emitVarLenCodeEmitter(RecordKeeper &R, raw_ostream &OS);5657} // end namespace llvm58#endif596061