Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.0.0git
Type.cpp
Go to the documentation of this file.
1//===- Type.cpp - Sandbox IR Type -----------------------------------------===//
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#include "llvm/SandboxIR/Type.h"
10#include "llvm/SandboxIR/Context.h"
11
12using namespacellvm::sandboxir;
13
14Type *Type::getScalarType() const{
15return Ctx.getType(LLVMTy->getScalarType());
16}
17
18Type *Type::getInt64Ty(Context &Ctx) {
19return Ctx.getType(llvm::Type::getInt64Ty(Ctx.LLVMCtx));
20}
21Type *Type::getInt32Ty(Context &Ctx) {
22return Ctx.getType(llvm::Type::getInt32Ty(Ctx.LLVMCtx));
23}
24Type *Type::getInt16Ty(Context &Ctx) {
25return Ctx.getType(llvm::Type::getInt16Ty(Ctx.LLVMCtx));
26}
27Type *Type::getInt8Ty(Context &Ctx) {
28return Ctx.getType(llvm::Type::getInt8Ty(Ctx.LLVMCtx));
29}
30Type *Type::getInt1Ty(Context &Ctx) {
31return Ctx.getType(llvm::Type::getInt1Ty(Ctx.LLVMCtx));
32}
33Type *Type::getDoubleTy(Context &Ctx) {
34return Ctx.getType(llvm::Type::getDoubleTy(Ctx.LLVMCtx));
35}
36Type *Type::getFloatTy(Context &Ctx) {
37return Ctx.getType(llvm::Type::getFloatTy(Ctx.LLVMCtx));
38}
39
40#ifndef NDEBUG
41voidType::dumpOS(raw_ostream &OS) { LLVMTy->print(OS); }
42voidType::dump() {
43 dumpOS(dbgs());
44dbgs() <<"\n";
45}
46#endif
47
48PointerType *PointerType::get(Context &Ctx,unsignedAddressSpace) {
49return cast<PointerType>(
50 Ctx.getType(llvm::PointerType::get(Ctx.LLVMCtx,AddressSpace)));
51}
52
53ArrayType *ArrayType::get(Type *ElementType,uint64_t NumElements) {
54return cast<ArrayType>(ElementType->getContext().getType(
55llvm::ArrayType::get(ElementType->LLVMTy, NumElements)));
56}
57
58StructType *StructType::get(Context &Ctx,ArrayRef<Type *> Elements,
59bool IsPacked) {
60SmallVector<llvm::Type *> LLVMElements;
61 LLVMElements.reserve(Elements.size());
62for (Type *Elm : Elements)
63 LLVMElements.push_back(Elm->LLVMTy);
64return cast<StructType>(
65 Ctx.getType(llvm::StructType::get(Ctx.LLVMCtx, LLVMElements, IsPacked)));
66}
67
68VectorType *VectorType::get(Type *ElementType,ElementCount EC) {
69return cast<VectorType>(ElementType->getContext().getType(
70llvm::VectorType::get(ElementType->LLVMTy, EC)));
71}
72
73Type *VectorType::getElementType() const{
74return Ctx.getType(cast<llvm::VectorType>(LLVMTy)->getElementType());
75}
76VectorType *VectorType::getInteger(VectorType *VTy) {
77return cast<VectorType>(VTy->getContext().getType(
78llvm::VectorType::getInteger(cast<llvm::VectorType>(VTy->LLVMTy))));
79}
80VectorType *VectorType::getExtendedElementVectorType(VectorType *VTy) {
81return cast<VectorType>(
82 VTy->getContext().getType(llvm::VectorType::getExtendedElementVectorType(
83 cast<llvm::VectorType>(VTy->LLVMTy))));
84}
85VectorType *VectorType::getTruncatedElementVectorType(VectorType *VTy) {
86return cast<VectorType>(
87 VTy->getContext().getType(llvm::VectorType::getTruncatedElementVectorType(
88 cast<llvm::VectorType>(VTy->LLVMTy))));
89}
90VectorType *VectorType::getSubdividedVectorType(VectorType *VTy,
91int NumSubdivs) {
92return cast<VectorType>(
93 VTy->getContext().getType(llvm::VectorType::getSubdividedVectorType(
94 cast<llvm::VectorType>(VTy->LLVMTy), NumSubdivs)));
95}
96VectorType *VectorType::getHalfElementsVectorType(VectorType *VTy) {
97return cast<VectorType>(
98 VTy->getContext().getType(llvm::VectorType::getHalfElementsVectorType(
99 cast<llvm::VectorType>(VTy->LLVMTy))));
100}
101VectorType *VectorType::getDoubleElementsVectorType(VectorType *VTy) {
102return cast<VectorType>(
103 VTy->getContext().getType(llvm::VectorType::getDoubleElementsVectorType(
104 cast<llvm::VectorType>(VTy->LLVMTy))));
105}
106boolVectorType::isValidElementType(Type *ElemTy) {
107returnllvm::VectorType::isValidElementType(ElemTy->LLVMTy);
108}
109
110FixedVectorType *FixedVectorType::get(Type *ElementType,unsigned NumElts) {
111return cast<FixedVectorType>(ElementType->getContext().getType(
112llvm::FixedVectorType::get(ElementType->LLVMTy, NumElts)));
113}
114
115ScalableVectorType *ScalableVectorType::get(Type *ElementType,
116unsigned NumElts) {
117return cast<ScalableVectorType>(ElementType->getContext().getType(
118llvm::ScalableVectorType::get(ElementType->LLVMTy, NumElts)));
119}
120
121IntegerType *IntegerType::get(Context &Ctx,unsigned NumBits) {
122return cast<IntegerType>(
123 Ctx.getType(llvm::IntegerType::get(Ctx.LLVMCtx, NumBits)));
124}
OS
raw_pwrite_stream & OS
Definition:SampleProfWriter.cpp:51
Context.h
Type.h
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition:ArrayRef.h:41
llvm::ArrayType::get
static ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
llvm::ElementCount
Definition:TypeSize.h:300
llvm::FixedVectorType
Class to represent fixed width SIMD vectors.
Definition:DerivedTypes.h:563
llvm::FixedVectorType::get
static FixedVectorType * get(Type *ElementType, unsigned NumElts)
Definition:Type.cpp:791
llvm::IntegerType
Class to represent integer types.
Definition:DerivedTypes.h:42
llvm::IntegerType::get
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
Definition:Type.cpp:311
llvm::PointerType::get
static PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
llvm::ScalableVectorType
Class to represent scalable SIMD vectors.
Definition:DerivedTypes.h:610
llvm::ScalableVectorType::get
static ScalableVectorType * get(Type *ElementType, unsigned MinNumElts)
Definition:Type.cpp:812
llvm::SmallVectorImpl::reserve
void reserve(size_type N)
Definition:SmallVector.h:663
llvm::SmallVectorTemplateBase::push_back
void push_back(const T &Elt)
Definition:SmallVector.h:413
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition:SmallVector.h:1196
llvm::StructType::get
static StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
Definition:Type.cpp:406
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition:Type.h:45
llvm::Type::getDoubleTy
static Type * getDoubleTy(LLVMContext &C)
llvm::Type::getInt1Ty
static IntegerType * getInt1Ty(LLVMContext &C)
llvm::Type::dump
void dump() const
llvm::Type::getInt16Ty
static IntegerType * getInt16Ty(LLVMContext &C)
llvm::Type::getInt8Ty
static IntegerType * getInt8Ty(LLVMContext &C)
llvm::Type::getInt32Ty
static IntegerType * getInt32Ty(LLVMContext &C)
llvm::Type::getInt64Ty
static IntegerType * getInt64Ty(LLVMContext &C)
llvm::Type::getFloatTy
static Type * getFloatTy(LLVMContext &C)
llvm::Type::getScalarType
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
Definition:Type.h:355
llvm::VectorType::getHalfElementsVectorType
static VectorType * getHalfElementsVectorType(VectorType *VTy)
This static method returns a VectorType with half as many elements as the input type and the same ele...
Definition:DerivedTypes.h:531
llvm::VectorType::getExtendedElementVectorType
static VectorType * getExtendedElementVectorType(VectorType *VTy)
This static method is like getInteger except that the element types are twice as wide as the elements...
Definition:DerivedTypes.h:487
llvm::VectorType::getSubdividedVectorType
static VectorType * getSubdividedVectorType(VectorType *VTy, int NumSubdivs)
Definition:DerivedTypes.h:521
llvm::VectorType::getInteger
static VectorType * getInteger(VectorType *VTy)
This static method gets a VectorType with the same number of elements as the input type,...
Definition:DerivedTypes.h:478
llvm::VectorType::get
static VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
llvm::VectorType::getTruncatedElementVectorType
static VectorType * getTruncatedElementVectorType(VectorType *VTy)
Definition:DerivedTypes.h:496
llvm::VectorType::isValidElementType
static bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
llvm::VectorType::getDoubleElementsVectorType
static VectorType * getDoubleElementsVectorType(VectorType *VTy)
This static method returns a VectorType with twice as many elements as the input type and the same el...
Definition:DerivedTypes.h:541
llvm::VectorType::getElementType
Type * getElementType() const
Definition:DerivedTypes.h:460
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition:raw_ostream.h:52
llvm::sandboxir::ArrayType
Definition:Type.h:302
llvm::sandboxir::Context
Definition:Context.h:30
llvm::sandboxir::Context::getType
Type * getType(llvm::Type *LLVMTy)
Definition:Context.h:239
llvm::sandboxir::Context::LLVMCtx
LLVMContext & LLVMCtx
Definition:Context.h:65
llvm::sandboxir::PointerType
Definition:Type.h:291
llvm::sandboxir::StructType
Definition:Type.h:311
llvm::sandboxir::Type
Just like llvm::Type these are immutable, unique, never get freed and can only be created via static ...
Definition:Type.h:43
llvm::sandboxir::Type::LLVMTy
llvm::Type * LLVMTy
Definition:Type.h:45
llvm::sandboxir::Type::dumpOS
void dumpOS(raw_ostream &OS)
llvm::sandboxir::Type::getContext
Context & getContext() const
Definition:Type.h:89
llvm::sandboxir::VectorType
Definition:Type.h:325
uint64_t
llvm::NVPTXAS::AddressSpace
AddressSpace
Definition:NVPTXAddrSpace.h:20
llvm::sandboxir
Definition:Argument.h:15
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition:Debug.cpp:163

Generated on Thu Jul 17 2025 12:30:59 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp