HLLabel* Compiler::newLabelNode() noexcept { Assembler* assembler = getAssembler(); if (assembler == nullptr) return nullptr; uint32_t id = assembler->_newLabelId(); LabelData* ld = assembler->getLabelData(id); HLLabel* node = newNode<HLLabel>(id); if (node == nullptr) return nullptr; // These have to be zero now. ASMJIT_ASSERT(ld->exId == 0); ASMJIT_ASSERT(ld->exData == nullptr); ld->exId = _exId; ld->exData = node; return node; }
bool MCWinCOFFStreamer::EmitSymbolAttribute(MCSymbol *S, MCSymbolAttr Attribute) { auto *Symbol = cast<MCSymbolCOFF>(S); getAssembler().registerSymbol(*Symbol); switch (Attribute) { default: return false; case MCSA_WeakReference: case MCSA_Weak: Symbol->setIsWeakExternal(); Symbol->setExternal(true); break; case MCSA_Global: Symbol->setExternal(true); break; case MCSA_AltEntry: llvm_unreachable("COFF doesn't support the .alt_entry attribute"); } return true; }
void Compiler::reset(bool releaseMemory) noexcept { Assembler* assembler = getAssembler(); if (assembler != nullptr) assembler->_detached(this); _arch = kArchNone; _regSize = 0; _finalized = false; _lastError = kErrorNotInitialized; _features = 0; _maxLookAhead = kCompilerDefaultLookAhead; _instOptions = 0; _tokenGenerator = 0; _nodeFlowId = 0; _nodeFlags = 0; _firstNode = nullptr; _lastNode = nullptr; _cursor = nullptr; _func = nullptr; _localConstPool.reset(); _globalConstPool.reset(); _localConstPoolLabel.reset(); _globalConstPoolLabel.reset(); _zoneAllocator.reset(releaseMemory); _varAllocator.reset(releaseMemory); _stringAllocator.reset(releaseMemory); _constAllocator.reset(releaseMemory); _varList.reset(releaseMemory); }
bool MCWinCOFFStreamer::EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) { assert(Symbol && "Symbol must be non-null!"); assert((!Symbol->isInSection() || Symbol->getSection().getVariant() == MCSection::SV_COFF) && "Got non-COFF section in the COFF backend!"); MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol); switch (Attribute) { default: return false; case MCSA_WeakReference: case MCSA_Weak: SD.modifyFlags(COFF::SF_WeakExternal, COFF::SF_WeakExternal); SD.setExternal(true); break; case MCSA_Global: SD.setExternal(true); break; } return true; }
bool MCWinCOFFStreamer::EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) { assert(Symbol && "Symbol must be non-null!"); assert((!Symbol->isInSection() || Symbol->getSection().getVariant() == MCSection::SV_COFF) && "Got non-COFF section in the COFF backend!"); getAssembler().registerSymbol(*Symbol); switch (Attribute) { default: return false; case MCSA_WeakReference: case MCSA_Weak: cast<MCSymbolCOFF>(Symbol)->setIsWeakExternal(); Symbol->setExternal(true); break; case MCSA_Global: Symbol->setExternal(true); break; } return true; }
void MCWinCOFFStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) { assert((!Symbol->isInSection() || Symbol->getSection().getVariant() == MCSection::SV_COFF) && "Got non-COFF section in the COFF backend!"); const Triple &T = getContext().getObjectFileInfo()->getTargetTriple(); if (T.isKnownWindowsMSVCEnvironment()) { if (ByteAlignment > 32) report_fatal_error("alignment is limited to 32-bytes"); // Round size up to alignment so that we will honor the alignment request. Size = std::max(Size, static_cast<uint64_t>(ByteAlignment)); } AssignSection(Symbol, nullptr); MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol); SD.setExternal(true); SD.setCommon(Size, ByteAlignment); if (!T.isKnownWindowsMSVCEnvironment() && ByteAlignment > 1) { SmallString<128> Directive; raw_svector_ostream OS(Directive); const MCObjectFileInfo *MFI = getContext().getObjectFileInfo(); OS << " -aligncomm:\"" << Symbol->getName() << "\"," << Log2_32_Ceil(ByteAlignment); OS.flush(); PushSection(); SwitchSection(MFI->getDrectveSection()); EmitBytes(Directive); PopSection(); } }
void MCWinCOFFStreamer::EmitFileDirective(StringRef Filename) { getAssembler().addFileName(Filename); }
bool Compiler::isLabelValid(uint32_t id) const noexcept { Assembler* assembler = getAssembler(); if (assembler == nullptr) return false; return static_cast<size_t>(id) < assembler->getLabelsCount(); }