0

rGeb66833d1957

 1 year ago
source link: https://reviews.llvm.org/rGeb66833d19573df97034a81279eda31b8d19815b
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

[clang][WebAssembly] Initial support for reference type externref in clang
Authored by pmatos on Jan 9 2023, 6:15 AM.
  • Restricted Project
  • Restricted Project
  • Restricted Project
Subscribers

Description

[clang][WebAssembly] Initial support for reference type externref in clang

This patch introduces a new type externref_t that denotes a WebAssembly opaque
reference type. It also implements builtin builtin_wasm_ref_null_extern(),
that returns a null value of __externref_t. This lays the ground work
for further builtins and reference types.

Differential Revision: https://reviews.llvm.org/D122215

rGeb66833d1957

clang/include/clang/AST/ASTContext.h

Show First 20 LinesShow All 1,120 Lines▼ Show 20 Lines
CanQualType SingletonId;
#include "clang/Basic/AArch64SVEACLETypes.def"
#define PPC_VECTOR_TYPE(Name, Id, Size) \
CanQualType Id##Ty;
#include "clang/Basic/PPCTypes.def"
#define RVV_TYPE(Name, Id, SingletonId) \
CanQualType SingletonId;
#include "clang/Basic/RISCVVTypes.def"
+ #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId;
+ #include "clang/Basic/WebAssemblyReferenceTypes.def"
// Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand.
mutable QualType AutoDeductTy; // Deduction against 'auto'.
mutable QualType AutoRRefDeductTy; // Deduction against 'auto &&'.
// Decl used to help define __builtin_va_list for some targets.
// The decl is built when constructing 'BuiltinVaListDecl'.
mutable Decl *VaListTagDecl = nullptr;
▲ Show 20 LinesShow All 332 Lines▼ Show 20 Lines
getBuiltinVectorTypeInfo(const BuiltinType *VecTy) const;
/// Return the unique reference to a scalable vector type of the specified
/// element type and scalable number of elements.
///
/// \pre \p EltTy must be a built-in type.
QualType getScalableVectorType(QualType EltTy, unsigned NumElts) const;
+ /// Return a WebAssembly externref type.
+ QualType getWebAssemblyExternrefType() const;
+
/// Return the unique reference to a vector type of the specified
/// element type and size.
///
/// \pre \p VectorType must be a built-in type.
QualType getVectorType(QualType VectorType, unsigned NumElts,
VectorType::VectorKind VecKind) const;
/// Return the unique reference to the type for a dependently sized vector of
/// the specified element type.
▲ Show 20 LinesShow All 1,977 LinesShow Last 20 Lines

clang/include/clang/AST/Type.h

  • This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 LinesShow All 2,023 Lines▼ Show 20 Lines
/// Sizeless types contain data with no specified size, alignment,
/// or layout.
bool isSizelessType() const;
bool isSizelessBuiltinType() const;
/// Returns true for SVE scalable vector types.
bool isSVESizelessBuiltinType() const;
+ /// Check if this is a WebAssembly Reference Type.
+ bool isWebAssemblyReferenceType() const;
+ bool isWebAssemblyExternrefType() const;
+
/// Determines if this is a sizeless type supported by the
/// 'arm_sve_vector_bits' type attribute, which can be applied to a single
/// SVE vector or predicate, excluding tuple types such as svint32x4_t.
bool isVLSTBuiltinType() const;
/// Returns the representative type for the element of an SVE builtin type.
/// This is used to represent fixed-length SVE vectors created with the
/// 'arm_sve_vector_bits' type attribute as VectorType.
▲ Show 20 LinesShow All 595 Lines▼ Show 20 Lines
#define SVE_TYPE(Name, Id, SingletonId) Id,
#include "clang/Basic/AArch64SVEACLETypes.def"
// PPC MMA Types
#define PPC_VECTOR_TYPE(Name, Id, Size) Id,
#include "clang/Basic/PPCTypes.def"
// RVV Types
#define RVV_TYPE(Name, Id, SingletonId) Id,
#include "clang/Basic/RISCVVTypes.def"
+ // WebAssembly reference types
+ #define WASM_TYPE(Name, Id, SingletonId) Id,
+ #include "clang/Basic/WebAssemblyReferenceTypes.def"
// All other builtin types
#define BUILTIN_TYPE(Id, SingletonId) Id,
#define LAST_BUILTIN_TYPE(Id) LastKind = Id
#include "clang/AST/BuiltinTypes.def"
};
private:
friend class ASTContext; // ASTContext creates these.
▲ Show 20 LinesShow All 4,854 LinesShow Last 20 Lines

clang/include/clang/AST/TypeProperties.td

Show First 20 LinesShow All 807 Lines▼ Show 20 Lines
#define PPC_VECTOR_TYPE(NAME, ID, SIZE) \
case BuiltinType::ID: return ctx.ID##Ty;
#include "clang/Basic/PPCTypes.def"
#define RVV_TYPE(NAME, ID, SINGLETON_ID) \
case BuiltinType::ID: return ctx.SINGLETON_ID;
#include "clang/Basic/RISCVVTypes.def"
+ #define WASM_TYPE(NAME, ID, SINGLETON_ID) \
+ case BuiltinType::ID: return ctx.SINGLETON_ID;
+ #include "clang/Basic/WebAssemblyReferenceTypes.def"
+
#define BUILTIN_TYPE(ID, SINGLETON_ID) \
case BuiltinType::ID: return ctx.SINGLETON_ID;
#include "clang/AST/BuiltinTypes.def"
}
llvm_unreachable("unreachable builtin case");
}]>;
}
▲ Show 20 LinesShow All 125 LinesShow Last 20 Lines

clang/include/clang/Basic/BuiltinsWebAssembly.def

Show First 20 LinesShow All 184 Lines▼ Show 20 Lines
TARGET_BUILTIN(__builtin_wasm_relaxed_trunc_u_zero_i32x4_f64x2, "V4UiV2d", "nc", "relaxed-simd")
TARGET_BUILTIN(__builtin_wasm_relaxed_q15mulr_s_i16x8, "V8sV8sV8s", "nc", "relaxed-simd")
TARGET_BUILTIN(__builtin_wasm_relaxed_dot_i8x16_i7x16_s_i16x8, "V8sV16ScV16Sc", "nc", "relaxed-simd")
TARGET_BUILTIN(__builtin_wasm_relaxed_dot_i8x16_i7x16_add_s_i32x4, "V4iV16ScV16ScV4i", "nc", "relaxed-simd")
TARGET_BUILTIN(__builtin_wasm_relaxed_dot_bf16x8_add_f32_f32x4, "V4fV8UsV8UsV4f", "nc", "relaxed-simd")
+ // Reference Types builtins
+
+ TARGET_BUILTIN(__builtin_wasm_ref_null_extern, "i", "nct", "reference-types")
+
#undef BUILTIN
#undef TARGET_BUILTIN

clang/include/clang/Basic/DiagnosticSemaKinds.td

Loading...

clang/include/clang/Basic/WebAssemblyReferenceTypes.def

Loading...

clang/include/clang/Sema/Sema.h

Loading...

clang/include/clang/Serialization/ASTBitCodes.h

Loading...

clang/include/clang/module.modulemap

Loading...

clang/lib/AST/ASTContext.cpp

Loading...

clang/lib/AST/ASTImporter.cpp

Loading...

clang/lib/AST/ExprConstant.cpp

Loading...

clang/lib/AST/ItaniumMangle.cpp

Loading...

clang/lib/AST/MicrosoftMangle.cpp

Loading...

clang/lib/AST/NSAPI.cpp

Loading...

clang/lib/AST/PrintfFormatString.cpp

Loading...

clang/lib/AST/Type.cpp

Loading...

clang/lib/AST/TypeLoc.cpp

Loading...

clang/lib/CodeGen/CGBuiltin.cpp

Loading...

clang/lib/CodeGen/CGDebugInfo.cpp

Loading...

clang/lib/CodeGen/CGDebugInfo.h

Loading...

clang/lib/CodeGen/CodeGenTypes.cpp

Loading...

clang/lib/CodeGen/ItaniumCXXABI.cpp

Loading...

clang/lib/CodeGen/TargetInfo.cpp

Loading...

clang/lib/CodeGen/TargetInfo.h

Loading...

clang/lib/Index/USRGeneration.cpp

Loading...

clang/lib/Sema/Sema.cpp

Loading...

clang/lib/Sema/SemaChecking.cpp

Loading...

clang/lib/Sema/SemaDecl.cpp

Loading...

clang/lib/Sema/SemaExpr.cpp

Loading...

clang/lib/Sema/SemaType.cpp

Loading...

clang/lib/Serialization/ASTCommon.cpp

Loading...

clang/lib/Serialization/ASTReader.cpp

Loading...

clang/test/CodeGen/WebAssembly/wasm-externref.c

Loading...

clang/test/CodeGen/builtins-wasm.c

Loading...

clang/test/CodeGenCXX/wasm-reftypes-mangle.cpp

Loading...

clang/test/CodeGenCXX/wasm-reftypes-typeinfo.cpp

Loading...

clang/test/Sema/wasm-refs.c

Loading...

clang/test/SemaCXX/wasm-refs.cpp

Loading...

clang/test/SemaTemplate/address_space-dependent.cpp

Loading...

clang/tools/libclang/CIndex.cpp

Loading...

llvm/include/llvm/IR/Type.h

Loading...

llvm/include/llvm/Transforms/Utils.h

Loading...

llvm/lib/CodeGen/ValueTypes.cpp

Loading...

llvm/lib/IR/Type.cpp

Loading...

llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp

Loading...

llvm/lib/Transforms/Utils/Mem2Reg.cpp

Loading...

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK