LLVM: include/llvm/Object/Wasm.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16#ifndef LLVM_OBJECT_WASM_H

17#define LLVM_OBJECT_WASM_H

18

22#include "llvm/Config/llvm-config.h"

29#include

30#include

31#include

32

33namespace llvm {

35

37public:

46

47

48

53

57

59

61

65

69

71

73

77

81

85

89

93

97

101

103

104#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)

106#endif

107};

108

121

126

128

129public:

131

137

139

143 return TargetFeatures;

144 }

164 void moveSymbolNext(DataRefImpl &Symb) const override;

165

167

169

172

173 bool is64Bit() const override { return false; }

174

184

185

186 void moveSectionNext(DataRefImpl &Sec) const override;

192 getSectionContents(DataRefImpl Sec) const override;

194 bool isSectionCompressed(DataRefImpl Sec) const override;

195 bool isSectionText(DataRefImpl Sec) const override;

196 bool isSectionData(DataRefImpl Sec) const override;

197 bool isSectionBSS(DataRefImpl Sec) const override;

198 bool isSectionVirtual(DataRefImpl Sec) const override;

201

202

203 void moveRelocationNext(DataRefImpl &Rel) const override;

207 void getRelocationTypeName(DataRefImpl Rel,

209

212 uint8_t getBytesInAddress() const override;

213 StringRef getFileFormatName() const override;

216 bool isRelocatableObject() const override;

217 bool isSharedObject() const;

219

225

226private:

227 bool isValidFunctionIndex(uint32_t Index) const;

228 bool isDefinedFunctionIndex(uint32_t Index) const;

229 bool isValidGlobalIndex(uint32_t Index) const;

230 bool isValidTableNumber(uint32_t Index) const;

231 bool isDefinedGlobalIndex(uint32_t Index) const;

232 bool isDefinedTableNumber(uint32_t Index) const;

233 bool isValidTagIndex(uint32_t Index) const;

234 bool isDefinedTagIndex(uint32_t Index) const;

235 bool isValidFunctionSymbol(uint32_t Index) const;

236 bool isValidTableSymbol(uint32_t Index) const;

237 bool isValidGlobalSymbol(uint32_t Index) const;

238 bool isValidTagSymbol(uint32_t Index) const;

239 bool isValidDataSymbol(uint32_t Index) const;

240 bool isValidSectionSymbol(uint32_t Index) const;

245

249

252

253

267

268

278

280 std::vector Sections;

283 std::vectorwasm::WasmFeatureEntry TargetFeatures;

284 std::vectorwasm::WasmSignature Signatures;

285 std::vectorwasm::WasmTable Tables;

286 std::vectorwasm::WasmLimits Memories;

287 std::vectorwasm::WasmGlobal Globals;

288 std::vectorwasm::WasmTag Tags;

289 std::vectorwasm::WasmImport Imports;

290 std::vectorwasm::WasmExport Exports;

291 std::vectorwasm::WasmElemSegment ElemSegments;

292 std::vector DataSegments;

293 std::optional<size_t> DataCount;

294 std::vectorwasm::WasmFunction Functions;

295 std::vector Symbols;

296 std::vectorwasm::WasmDebugName DebugNames;

298 bool HasLinkingSection = false;

299 bool HasDylinkSection = false;

300 bool HasMemory64 = false;

301 bool HasUnmodeledTypes = false;

303 uint32_t NumImportedGlobals = 0;

304 uint32_t NumImportedTables = 0;

305 uint32_t NumImportedFunctions = 0;

306 uint32_t NumImportedTags = 0;

312};

313

315public:

316

317 enum : int {

318

320

321

335

336

337

339

341

343

344

346

348

350

351

353

354 };

355

356

359

361 StringRef CustomSectionName = "");

362

363private:

364 bool Seen[WASM_NUM_SEC_ORDERS] = {};

365

366

367 int getSectionOrder(unsigned ID, StringRef CustomSectionName = "");

368};

369

370}

371

376

377}

378

379#endif

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

static StringRef getSymbolName(SymbolKind SymKind)

#define LLVM_DUMP_METHOD

Mark debug helper function definitions like dump() that should not be stripped from debug builds.

static FeatureBitset getFeatures(MCSubtargetInfo &STI, StringRef CPU, StringRef TuneCPU, StringRef FS, ArrayRef< StringRef > ProcNames, ArrayRef< SubtargetSubTypeKV > ProcDesc, ArrayRef< SubtargetFeatureKV > ProcFeatures)

static std::unique_ptr< PDBSymbol > getSymbolType(const PDBSymbol &Symbol)

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...

Lightweight error class with error context and mandatory checking.

Tagged union holding either a T or a Error.

This class consists of common code factored out of the SmallVector class to reduce code duplication b...

StringRef - Represent a constant reference to a string, i.e.

friend class RelocationRef

ObjectFile(unsigned int Type, MemoryBufferRef Source)

This is a value type class that represents a single symbol in the list of symbols in the object file.

ArrayRef< wasm::WasmSignature > types() const

Definition Wasm.h:145

ArrayRef< wasm::WasmElemSegment > elements() const

Definition Wasm.h:154

const wasm::WasmProducerInfo & getProducerInfo() const

Definition Wasm.h:141

bool hasUnmodeledTypes() const

Definition Wasm.h:218

uint32_t startFunction() const

Definition Wasm.h:158

uint32_t getNumberOfSymbols() const

Definition Wasm.h:153

ArrayRef< wasm::WasmLimits > memories() const

Definition Wasm.h:148

bool is64Bit() const override

Definition Wasm.h:173

ArrayRef< wasm::WasmExport > exports() const

Definition Wasm.h:151

uint32_t getNumImportedTags() const

Definition Wasm.h:162

ArrayRef< wasm::WasmImport > imports() const

Definition Wasm.h:146

ArrayRef< wasm::WasmTag > tags() const

Definition Wasm.h:150

WasmObjectFile(MemoryBufferRef Object, Error &Err)

ArrayRef< wasm::WasmDebugName > debugNames() const

Definition Wasm.h:157

const wasm::WasmLinkingData & linkingData() const

Definition Wasm.h:152

ArrayRef< wasm::WasmFeatureEntry > getTargetFeatures() const

Definition Wasm.h:142

uint32_t getNumImportedTables() const

Definition Wasm.h:160

const WasmSection & getWasmSection(const SectionRef &Section) const

static bool classof(const Binary *v)

Definition Wasm.h:138

ArrayRef< wasm::WasmGlobal > globals() const

Definition Wasm.h:149

ArrayRef< wasm::WasmTable > tables() const

Definition Wasm.h:147

const wasm::WasmObjectHeader & getHeader() const

uint32_t getNumImportedFunctions() const

Definition Wasm.h:161

ArrayRef< WasmSegment > dataSegments() const

Definition Wasm.h:155

const wasm::WasmRelocation & getWasmRelocation(const RelocationRef &Ref) const

const wasm::WasmDylinkInfo & dylinkInfo() const

Definition Wasm.h:140

ArrayRef< wasm::WasmFunction > functions() const

Definition Wasm.h:156

const WasmSymbol & getWasmSymbol(const DataRefImpl &Symb) const

uint32_t getNumImportedGlobals() const

Definition Wasm.h:159

uint32_t getNumSections() const

Definition Wasm.h:163

LLVM_ABI bool isValidSectionOrder(unsigned ID, StringRef CustomSectionName="")

@ WASM_SEC_ORDER_TYPE

Definition Wasm.h:322

@ WASM_SEC_ORDER_TARGET_FEATURES

Definition Wasm.h:349

@ WASM_SEC_ORDER_NONE

Definition Wasm.h:319

@ WASM_SEC_ORDER_MEMORY

Definition Wasm.h:326

@ WASM_SEC_ORDER_PRODUCERS

Definition Wasm.h:347

@ WASM_SEC_ORDER_CODE

Definition Wasm.h:333

@ WASM_SEC_ORDER_START

Definition Wasm.h:330

@ WASM_SEC_ORDER_RELOC

Definition Wasm.h:342

@ WASM_SEC_ORDER_NAME

Definition Wasm.h:345

@ WASM_SEC_ORDER_DYLINK

Definition Wasm.h:338

@ WASM_SEC_ORDER_LINKING

Definition Wasm.h:340

@ WASM_SEC_ORDER_DATA

Definition Wasm.h:334

@ WASM_SEC_ORDER_TABLE

Definition Wasm.h:325

@ WASM_NUM_SEC_ORDERS

Definition Wasm.h:352

@ WASM_SEC_ORDER_ELEM

Definition Wasm.h:331

@ WASM_SEC_ORDER_GLOBAL

Definition Wasm.h:328

@ WASM_SEC_ORDER_EXPORT

Definition Wasm.h:329

@ WASM_SEC_ORDER_TAG

Definition Wasm.h:327

@ WASM_SEC_ORDER_IMPORT

Definition Wasm.h:323

@ WASM_SEC_ORDER_DATACOUNT

Definition Wasm.h:332

@ WASM_SEC_ORDER_FUNCTION

Definition Wasm.h:324

static LLVM_ABI int DisallowedPredecessors[WASM_NUM_SEC_ORDERS][WASM_NUM_SEC_ORDERS]

Definition Wasm.h:358

bool isTypeFunction() const

Definition Wasm.h:54

unsigned getBinding() const

Definition Wasm.h:90

LLVM_DUMP_METHOD void dump() const

bool isTypeData() const

Definition Wasm.h:60

bool isTypeTable() const

Definition Wasm.h:58

bool isBindingWeak() const

Definition Wasm.h:78

bool isTypeSection() const

Definition Wasm.h:66

bool isHidden() const

Definition Wasm.h:94

bool isBindingGlobal() const

Definition Wasm.h:82

unsigned getVisibility() const

Definition Wasm.h:98

wasm::WasmSymbolInfo Info

Definition Wasm.h:49

bool isUndefined() const

Definition Wasm.h:74

const wasm::WasmGlobalType * GlobalType

Definition Wasm.h:50

WasmSymbol(const wasm::WasmSymbolInfo &Info, const wasm::WasmGlobalType *GlobalType, const wasm::WasmTableType *TableType, const wasm::WasmSignature *Signature)

Definition Wasm.h:38

LLVM_ABI void print(raw_ostream &Out) const

const wasm::WasmTableType * TableType

Definition Wasm.h:51

bool isTypeTag() const

Definition Wasm.h:70

bool isBindingLocal() const

Definition Wasm.h:86

bool isTypeGlobal() const

Definition Wasm.h:62

const wasm::WasmSignature * Signature

Definition Wasm.h:52

bool isDefined() const

Definition Wasm.h:72

This class implements an extremely fast bulk output stream that can only output to a stream.

unsigned ID

LLVM IR allows to use arbitrary numbers as calling convention identifiers.

static constexpr const StringLiteral & getSectionName(DebugSectionKind SectionKind)

Return the name of the section.

content_iterator< SectionRef > section_iterator

content_iterator< BasicSymbolRef > basic_symbol_iterator

content_iterator< RelocationRef > relocation_iterator

const unsigned WASM_SYMBOL_UNDEFINED

const unsigned WASM_SYMBOL_BINDING_GLOBAL

const unsigned WASM_SYMBOL_BINDING_WEAK

const unsigned WASM_SYMBOL_BINDING_LOCAL

@ WASM_SYMBOL_TYPE_GLOBAL

@ WASM_SYMBOL_TYPE_SECTION

@ WASM_SYMBOL_TYPE_FUNCTION

const unsigned WASM_SYMBOL_BINDING_MASK

const unsigned WASM_SYMBOL_VISIBILITY_MASK

const unsigned WASM_SYMBOL_VISIBILITY_HIDDEN

This is an optimization pass for GlobalISel generic memory operations.

@ Ref

The access may reference the value stored in memory.

raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)

const uint8_t * End

Definition Wasm.h:223

const uint8_t * Start

Definition Wasm.h:221

const uint8_t * Ptr

Definition Wasm.h:222

ArrayRef< uint8_t > Content

Definition Wasm.h:116

uint32_t Comdat

Definition Wasm.h:115

StringRef Name

Definition Wasm.h:114

std::vector< wasm::WasmRelocation > Relocations

Definition Wasm.h:117

std::optional< uint8_t > HeaderSecSizeEncodingLen

Definition Wasm.h:119

uint32_t Offset

Definition Wasm.h:113

uint32_t Type

Definition Wasm.h:112

wasm::WasmDataSegment Data

Definition Wasm.h:124

uint32_t SectionOffset

Definition Wasm.h:123