├── BitCodeInterpreter.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ └── xcuserdata │ │ └── jintao.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── jintao.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ └── xcschememanagement.plist ├── BitCodeInterpreter ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ ├── AccentColor.colorset │ │ └── Contents.json │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── BitCodeInterpreter │ └── llvm │ │ ├── ADT │ │ ├── APFixedPoint.h │ │ ├── APFloat.h │ │ ├── APInt.h │ │ ├── APSInt.h │ │ ├── AllocatorList.h │ │ ├── Any.h │ │ ├── ArrayRef.h │ │ ├── BitVector.h │ │ ├── Bitfields.h │ │ ├── BitmaskEnum.h │ │ ├── BreadthFirstIterator.h │ │ ├── CachedHashString.h │ │ ├── CoalescingBitVector.h │ │ ├── DAGDeltaAlgorithm.h │ │ ├── DeltaAlgorithm.h │ │ ├── DenseMap.h │ │ ├── DenseMapInfo.h │ │ ├── DenseSet.h │ │ ├── DepthFirstIterator.h │ │ ├── DirectedGraph.h │ │ ├── EnumeratedArray.h │ │ ├── EpochTracker.h │ │ ├── EquivalenceClasses.h │ │ ├── FloatingPointMode.h │ │ ├── FoldingSet.h │ │ ├── FunctionExtras.h │ │ ├── GraphTraits.h │ │ ├── Hashing.h │ │ ├── ImmutableList.h │ │ ├── ImmutableMap.h │ │ ├── ImmutableSet.h │ │ ├── IndexedMap.h │ │ ├── IntEqClasses.h │ │ ├── IntervalMap.h │ │ ├── IntrusiveRefCntPtr.h │ │ ├── MapVector.h │ │ ├── None.h │ │ ├── Optional.h │ │ ├── PackedVector.h │ │ ├── PointerEmbeddedInt.h │ │ ├── PointerIntPair.h │ │ ├── PointerSumType.h │ │ ├── PointerUnion.h │ │ ├── PostOrderIterator.h │ │ ├── PriorityQueue.h │ │ ├── PriorityWorklist.h │ │ ├── SCCIterator.h │ │ ├── STLExtras.h │ │ ├── ScopeExit.h │ │ ├── ScopedHashTable.h │ │ ├── Sequence.h │ │ ├── SetOperations.h │ │ ├── SetVector.h │ │ ├── SmallBitVector.h │ │ ├── SmallPtrSet.h │ │ ├── SmallSet.h │ │ ├── SmallString.h │ │ ├── SmallVector.h │ │ ├── SparseBitVector.h │ │ ├── SparseMultiSet.h │ │ ├── SparseSet.h │ │ ├── Statistic.h │ │ ├── StringExtras.h │ │ ├── StringMap.h │ │ ├── StringMapEntry.h │ │ ├── StringRef.h │ │ ├── StringSet.h │ │ ├── StringSwitch.h │ │ ├── TinyPtrVector.h │ │ ├── Triple.h │ │ ├── Twine.h │ │ ├── TypeSwitch.h │ │ ├── UniqueVector.h │ │ ├── Waymarking.h │ │ ├── bit.h │ │ ├── edit_distance.h │ │ ├── fallible_iterator.h │ │ ├── ilist.h │ │ ├── ilist_base.h │ │ ├── ilist_iterator.h │ │ ├── ilist_node.h │ │ ├── ilist_node_base.h │ │ ├── ilist_node_options.h │ │ ├── iterator.h │ │ ├── iterator_range.h │ │ └── simple_ilist.h │ │ ├── AsmParser │ │ ├── LLLexer.cpp │ │ ├── LLLexer.h │ │ ├── LLParser.cpp │ │ ├── LLParser.h │ │ ├── LLToken.h │ │ ├── Parser.cpp │ │ ├── Parser.h │ │ └── SlotMapping.h │ │ ├── Basic │ │ └── LLVM.h │ │ ├── BinaryFormat │ │ ├── COFF.h │ │ ├── Dwarf.cpp │ │ ├── Dwarf.def │ │ ├── Dwarf.h │ │ ├── ELF.h │ │ ├── MachO.cpp │ │ ├── MachO.def │ │ ├── MachO.h │ │ ├── Magic.cpp │ │ ├── Magic.h │ │ └── XCOFF.h │ │ ├── Bitcode │ │ ├── BitReader.cpp │ │ ├── BitcodeAnalyzer.cpp │ │ ├── BitcodeAnalyzer.h │ │ ├── BitcodeCommon.h │ │ ├── BitcodeReader.cpp │ │ ├── BitcodeReader.h │ │ ├── LLVMBitCodes.h │ │ ├── MetadataLoader.cpp │ │ ├── MetadataLoader.h │ │ ├── ValueList.cpp │ │ └── ValueList.h │ │ ├── Bitstream │ │ ├── BitCodes.h │ │ ├── BitstreamReader.cpp │ │ ├── BitstreamReader.h │ │ └── BitstreamWriter.h │ │ ├── CodeGen │ │ ├── IntrinsicLowering.cpp │ │ └── IntrinsicLowering.h │ │ ├── Config │ │ ├── AsmParsers.def │ │ ├── AsmPrinters.def │ │ ├── Disassemblers.def │ │ ├── Targets.def │ │ ├── abi-breaking.h │ │ ├── config.h │ │ └── llvm-config.h │ │ ├── DebugInfo │ │ ├── CodeView │ │ │ ├── CVRecord.h │ │ │ ├── CodeView.h │ │ │ ├── CodeViewError.h │ │ │ ├── CodeViewRegisters.def │ │ │ ├── CodeViewSymbols.def │ │ │ ├── CodeViewTypes.def │ │ │ ├── Line.h │ │ │ ├── RecordSerialization.h │ │ │ ├── SymbolRecord.h │ │ │ └── TypeIndex.h │ │ └── DIContext.h │ │ ├── Demangle │ │ ├── Demangle.cpp │ │ ├── Demangle.h │ │ ├── DemangleConfig.h │ │ ├── ItaniumDemangle.cpp │ │ ├── ItaniumDemangle.h │ │ ├── MicrosoftDemangle.cpp │ │ ├── MicrosoftDemangle.h │ │ ├── MicrosoftDemangleNodes.cpp │ │ ├── MicrosoftDemangleNodes.h │ │ ├── StringView.h │ │ └── Utility.h │ │ ├── ExecutionEngine │ │ ├── ExecutionEngine.cpp │ │ ├── ExecutionEngine.h │ │ ├── GenericValue.h │ │ ├── ObjectCache.h │ │ └── OrcV1Deprecation.h │ │ ├── IR │ │ ├── AbstractCallSite.h │ │ ├── Argument.h │ │ ├── AssemblyAnnotationWriter.h │ │ ├── Assumptions.h │ │ ├── Attributes.h │ │ ├── Attributes.inc │ │ ├── Attributes.td │ │ ├── AutoUpgrade.h │ │ ├── BasicBlock.h │ │ ├── CFG.h │ │ ├── CallingConv.h │ │ ├── Comdat.h │ │ ├── Constant.h │ │ ├── ConstantFolder.h │ │ ├── ConstantRange.h │ │ ├── Constants.h │ │ ├── ConstrainedOps.def │ │ ├── DIBuilder.h │ │ ├── DataLayout.h │ │ ├── DebugInfo.h │ │ ├── DebugInfoFlags.def │ │ ├── DebugInfoMetadata.h │ │ ├── DebugLoc.h │ │ ├── DerivedTypes.h │ │ ├── DerivedUser.h │ │ ├── DiagnosticHandler.h │ │ ├── DiagnosticInfo.h │ │ ├── DiagnosticPrinter.h │ │ ├── Dominators.h │ │ ├── FPEnv.h │ │ ├── FixedMetadataKinds.def │ │ ├── FixedPointBuilder.h │ │ ├── Function.h │ │ ├── GVMaterializer.h │ │ ├── GetElementPtrTypeIterator.h │ │ ├── GlobalAlias.h │ │ ├── GlobalIFunc.h │ │ ├── GlobalIndirectSymbol.h │ │ ├── GlobalObject.h │ │ ├── GlobalPtrAuthInfo.h │ │ ├── GlobalValue.h │ │ ├── GlobalVariable.h │ │ ├── IRBuilder.h │ │ ├── IRBuilderFolder.h │ │ ├── IRPrintingPasses.h │ │ ├── InlineAsm.h │ │ ├── InstIterator.h │ │ ├── InstVisitor.h │ │ ├── InstrTypes.h │ │ ├── Instruction.def │ │ ├── Instruction.h │ │ ├── Instructions.h │ │ ├── IntrinsicEnums.inc │ │ ├── IntrinsicImpl.inc │ │ ├── IntrinsicInst.h │ │ ├── Intrinsics.h │ │ ├── Intrinsics.td │ │ ├── IntrinsicsAArch64.h │ │ ├── IntrinsicsAMDGPU.h │ │ ├── IntrinsicsARM.h │ │ ├── IntrinsicsBPF.h │ │ ├── IntrinsicsHexagon.h │ │ ├── IntrinsicsMips.h │ │ ├── IntrinsicsNVPTX.h │ │ ├── IntrinsicsPowerPC.h │ │ ├── IntrinsicsR600.h │ │ ├── IntrinsicsRISCV.h │ │ ├── IntrinsicsS390.h │ │ ├── IntrinsicsVE.h │ │ ├── IntrinsicsWebAssembly.h │ │ ├── IntrinsicsX86.h │ │ ├── IntrinsicsXCore.h │ │ ├── LLVMContext.h │ │ ├── LLVMRemarkStreamer.h │ │ ├── LegacyPassManager.h │ │ ├── LegacyPassManagers.h │ │ ├── LegacyPassNameParser.h │ │ ├── MDBuilder.h │ │ ├── Mangler.h │ │ ├── MatrixBuilder.h │ │ ├── Metadata.def │ │ ├── Metadata.h │ │ ├── Module.h │ │ ├── ModuleSlotTracker.h │ │ ├── ModuleSummaryIndex.h │ │ ├── ModuleSummaryIndexYAML.h │ │ ├── NoFolder.h │ │ ├── OperandTraits.h │ │ ├── Operator.h │ │ ├── OptBisect.h │ │ ├── PassInstrumentation.h │ │ ├── PassManager.h │ │ ├── PassManagerImpl.h │ │ ├── PassManagerInternal.h │ │ ├── PassTimingInfo.h │ │ ├── PatternMatch.h │ │ ├── PredIteratorCache.h │ │ ├── PrintPasses.h │ │ ├── ProfileSummary.h │ │ ├── PseudoProbe.h │ │ ├── RuntimeLibcalls.def │ │ ├── SafepointIRVerifier.h │ │ ├── Statepoint.h │ │ ├── StructuralHash.h │ │ ├── SymbolTableListTraits.h │ │ ├── TrackingMDRef.h │ │ ├── Type.h │ │ ├── TypeFinder.h │ │ ├── Use.h │ │ ├── UseListOrder.h │ │ ├── User.h │ │ ├── VPIntrinsics.def │ │ ├── Value.def │ │ ├── Value.h │ │ ├── ValueHandle.h │ │ ├── ValueMap.h │ │ ├── ValueSymbolTable.h │ │ └── Verifier.h │ │ ├── IRReader │ │ ├── IRReader.cpp │ │ └── IRReader.h │ │ ├── InitializePasses.h │ │ ├── Interpreter │ │ ├── Execution.cpp │ │ ├── ExternalFunctions.cpp │ │ ├── Interpreter.cpp │ │ └── Interpreter.h │ │ ├── MC │ │ ├── ConstantPools.cpp │ │ ├── ConstantPools.h │ │ ├── LaneBitmask.h │ │ ├── MCAsmBackend.h │ │ ├── MCAsmInfo.h │ │ ├── MCAsmLayout.h │ │ ├── MCAsmMacro.h │ │ ├── MCAssembler.cpp │ │ ├── MCAssembler.h │ │ ├── MCCodeEmitter.cpp │ │ ├── MCCodeEmitter.h │ │ ├── MCCodeView.cpp │ │ ├── MCCodeView.h │ │ ├── MCContext.cpp │ │ ├── MCContext.h │ │ ├── MCDirectives.h │ │ ├── MCDwarf.cpp │ │ ├── MCDwarf.h │ │ ├── MCExpr.cpp │ │ ├── MCExpr.h │ │ ├── MCFixedLenDisassembler.h │ │ ├── MCFixup.h │ │ ├── MCFixupKindInfo.h │ │ ├── MCFragment.cpp │ │ ├── MCFragment.h │ │ ├── MCInst.cpp │ │ ├── MCInst.h │ │ ├── MCInstBuilder.h │ │ ├── MCInstPrinter.cpp │ │ ├── MCInstPrinter.h │ │ ├── MCInstrAnalysis.cpp │ │ ├── MCInstrAnalysis.h │ │ ├── MCInstrDesc.cpp │ │ ├── MCInstrDesc.h │ │ ├── MCInstrInfo.cpp │ │ ├── MCInstrInfo.h │ │ ├── MCInstrItineraries.h │ │ ├── MCLabel.cpp │ │ ├── MCLabel.h │ │ ├── MCLinkerOptimizationHint.cpp │ │ ├── MCLinkerOptimizationHint.h │ │ ├── MCMachOStreamer.cpp │ │ ├── MCMachObjectTargetWriter.cpp │ │ ├── MCMachObjectWriter.h │ │ ├── MCNullStreamer.cpp │ │ ├── MCObjectFileInfo.cpp │ │ ├── MCObjectFileInfo.h │ │ ├── MCObjectStreamer.cpp │ │ ├── MCObjectStreamer.h │ │ ├── MCObjectWriter.cpp │ │ ├── MCObjectWriter.h │ │ ├── MCParser │ │ │ ├── AsmCond.h │ │ │ ├── AsmLexer.cpp │ │ │ ├── AsmLexer.h │ │ │ ├── AsmParser.cpp │ │ │ ├── DarwinAsmParser.cpp │ │ │ ├── MCAsmLexer.cpp │ │ │ ├── MCAsmLexer.h │ │ │ ├── MCAsmParser.cpp │ │ │ ├── MCAsmParser.h │ │ │ ├── MCAsmParserExtension.cpp │ │ │ ├── MCAsmParserExtension.h │ │ │ ├── MCAsmParserUtils.h │ │ │ ├── MCParsedAsmOperand.h │ │ │ ├── MCTargetAsmParser.cpp │ │ │ └── MCTargetAsmParser.h │ │ ├── MCPseudoProbe.cpp │ │ ├── MCPseudoProbe.h │ │ ├── MCRegister.h │ │ ├── MCRegisterInfo.cpp │ │ ├── MCRegisterInfo.h │ │ ├── MCSchedule.cpp │ │ ├── MCSchedule.h │ │ ├── MCSection.cpp │ │ ├── MCSection.h │ │ ├── MCSectionMachO.cpp │ │ ├── MCSectionMachO.h │ │ ├── MCStreamer.cpp │ │ ├── MCStreamer.h │ │ ├── MCSubtargetInfo.cpp │ │ ├── MCSubtargetInfo.h │ │ ├── MCSymbol.cpp │ │ ├── MCSymbol.h │ │ ├── MCSymbolMachO.h │ │ ├── MCTargetOptions.cpp │ │ ├── MCTargetOptions.h │ │ ├── MCTargetOptionsCommandFlags.cpp │ │ ├── MCTargetOptionsCommandFlags.h │ │ ├── MCValue.cpp │ │ ├── MCValue.h │ │ ├── MCWinEH.h │ │ ├── MachObjectWriter.cpp │ │ ├── MachineLocation.h │ │ ├── SectionKind.h │ │ ├── StringTableBuilder.cpp │ │ ├── StringTableBuilder.h │ │ ├── SubtargetFeature.cpp │ │ └── SubtargetFeature.h │ │ ├── Object │ │ ├── Archive.cpp │ │ ├── Archive.h │ │ ├── ArchiveWriter.cpp │ │ ├── ArchiveWriter.h │ │ ├── Binary.cpp │ │ ├── Binary.h │ │ ├── COFF.h │ │ ├── COFFImportFile.cpp │ │ ├── COFFImportFile.h │ │ ├── CVDebugRecord.h │ │ ├── Error.cpp │ │ ├── Error.h │ │ ├── IRObjectFile.cpp │ │ ├── IRObjectFile.h │ │ ├── IRSymtab.cpp │ │ ├── IRSymtab.h │ │ ├── MachO.h │ │ ├── MachOObjectFile.cpp │ │ ├── MachOUniversal.cpp │ │ ├── MachOUniversal.h │ │ ├── ModuleSymbolTable.cpp │ │ ├── ModuleSymbolTable.h │ │ ├── ObjectFile.cpp │ │ ├── ObjectFile.h │ │ ├── RecordStreamer.cpp │ │ ├── RecordStreamer.h │ │ ├── SymbolicFile.cpp │ │ ├── SymbolicFile.h │ │ └── Wasm.h │ │ ├── Pass.h │ │ ├── PassAnalysisSupport.h │ │ ├── PassInfo.h │ │ ├── PassRegistry.h │ │ ├── PassSupport.h │ │ ├── Remarks │ │ ├── BitstreamRemarkContainer.h │ │ ├── BitstreamRemarkParser 2.h │ │ ├── BitstreamRemarkParser.cpp │ │ ├── BitstreamRemarkParser.h │ │ ├── BitstreamRemarkSerializer.cpp │ │ ├── BitstreamRemarkSerializer.h │ │ ├── Remark.cpp │ │ ├── Remark.h │ │ ├── RemarkFormat.cpp │ │ ├── RemarkFormat.h │ │ ├── RemarkParser.cpp │ │ ├── RemarkParser.h │ │ ├── RemarkSerializer.cpp │ │ ├── RemarkSerializer.h │ │ ├── RemarkStreamer.cpp │ │ ├── RemarkStreamer.h │ │ ├── RemarkStringTable.cpp │ │ ├── RemarkStringTable.h │ │ ├── YAMLRemarkParser.cpp │ │ ├── YAMLRemarkParser.h │ │ ├── YAMLRemarkSerializer.cpp │ │ └── YAMLRemarkSerializer.h │ │ ├── Support │ │ ├── AArch64TargetParser.def │ │ ├── AArch64TargetParser.h │ │ ├── AMDGPUMetadata.h │ │ ├── AMDHSAKernelDescriptor.h │ │ ├── ARMAttributeParser.h │ │ ├── ARMBuildAttributes.h │ │ ├── ARMEHABI.h │ │ ├── ARMTargetParser.def │ │ ├── ARMTargetParser.h │ │ ├── ARMWinEH.h │ │ ├── AlignOf.h │ │ ├── Alignment.h │ │ ├── Allocator.h │ │ ├── AllocatorBase.h │ │ ├── ArrayRecycler.h │ │ ├── Atomic.h │ │ ├── AtomicOrdering.h │ │ ├── Automaton.h │ │ ├── Base64.h │ │ ├── BinaryByteStream.h │ │ ├── BinaryItemStream.h │ │ ├── BinaryStream.h │ │ ├── BinaryStreamArray.h │ │ ├── BinaryStreamError.h │ │ ├── BinaryStreamReader.h │ │ ├── BinaryStreamRef.h │ │ ├── BinaryStreamWriter.h │ │ ├── BlockFrequency.h │ │ ├── BranchProbability.h │ │ ├── BuryPointer.h │ │ ├── CBindingWrapping.h │ │ ├── CFGDiff.h │ │ ├── CFGUpdate.h │ │ ├── COM.h │ │ ├── CRC.h │ │ ├── CachePruning.h │ │ ├── Capacity.h │ │ ├── Casting.h │ │ ├── CheckedArithmetic.h │ │ ├── Chrono.h │ │ ├── CodeGen.h │ │ ├── CodeGenCoverage.h │ │ ├── CommandLine.h │ │ ├── Compiler.h │ │ ├── Compression.h │ │ ├── ConvertUTF.h │ │ ├── CrashRecoveryContext.h │ │ ├── DJB.h │ │ ├── DOTGraphTraits.h │ │ ├── DataExtractor.h │ │ ├── DataTypes.h │ │ ├── Debug.h │ │ ├── DebugCounter.h │ │ ├── DynamicLibrary.h │ │ ├── ELFAttributeParser.h │ │ ├── ELFAttributes.h │ │ ├── Endian.h │ │ ├── EndianStream.h │ │ ├── Errc.h │ │ ├── Errno.h │ │ ├── Error.h │ │ ├── ErrorHandling.h │ │ ├── ErrorOr.h │ │ ├── ExitCodes.h │ │ ├── ExtensibleRTTI.h │ │ ├── FileCollector.h │ │ ├── FileOutputBuffer.h │ │ ├── FileSystem.h │ │ ├── FileSystem │ │ │ └── UniqueID.h │ │ ├── FileUtilities.h │ │ ├── Format.h │ │ ├── FormatAdapters.h │ │ ├── FormatCommon.h │ │ ├── FormatProviders.h │ │ ├── FormatVariadic.h │ │ ├── FormatVariadicDetails.h │ │ ├── FormattedStream.h │ │ ├── GenericDomTree.h │ │ ├── GenericDomTreeConstruction.h │ │ ├── GenericIteratedDominanceFrontier.h │ │ ├── GlobPattern.h │ │ ├── GraphWriter.h │ │ ├── Host.h │ │ ├── InitLLVM.h │ │ ├── InstructionCost.h │ │ ├── ItaniumManglingCanonicalizer.h │ │ ├── JSON.h │ │ ├── KnownBits.h │ │ ├── LEB128.h │ │ ├── LICENSE.TXT │ │ ├── LineIterator.h │ │ ├── Locale.h │ │ ├── LockFileManager.h │ │ ├── LowLevelTypeImpl.h │ │ ├── MD5.h │ │ ├── MSVCErrorWorkarounds.h │ │ ├── MachineValueType.h │ │ ├── ManagedStatic.h │ │ ├── MathExtras.h │ │ ├── MemAlloc.h │ │ ├── Memory.h │ │ ├── MemoryBuffer.h │ │ ├── MemoryBufferRef.h │ │ ├── MipsABIFlags.h │ │ ├── Mutex.h │ │ ├── NativeFormatting.h │ │ ├── OnDiskHashTable.h │ │ ├── OptimizedStructLayout.h │ │ ├── Parallel.h │ │ ├── Path.h │ │ ├── PluginLoader.h │ │ ├── PointerLikeTypeTraits.h │ │ ├── PrettyStackTrace.h │ │ ├── Printable.h │ │ ├── Process.h │ │ ├── Program.h │ │ ├── RISCVAttributeParser.h │ │ ├── RISCVAttributes.h │ │ ├── RISCVTargetParser.def │ │ ├── RWMutex.h │ │ ├── RandomNumberGenerator.h │ │ ├── Recycler.h │ │ ├── RecyclingAllocator.h │ │ ├── Regex.h │ │ ├── Registry.h │ │ ├── ReverseIteration.h │ │ ├── SHA1.h │ │ ├── SMLoc.h │ │ ├── SMTAPI.h │ │ ├── SaveAndRestore.h │ │ ├── ScaledNumber.h │ │ ├── ScopedPrinter.h │ │ ├── Signals.h │ │ ├── Signposts.h │ │ ├── SmallVectorMemoryBuffer.h │ │ ├── Solaris │ │ │ └── sys │ │ │ │ └── regset.h │ │ ├── SourceMgr.h │ │ ├── SpecialCaseList.h │ │ ├── StringSaver.h │ │ ├── SuffixTree.h │ │ ├── SwapByteOrder.h │ │ ├── SymbolRemappingReader.h │ │ ├── SystemUtils.h │ │ ├── TarWriter.h │ │ ├── TargetOpcodes.def │ │ ├── TargetParser.h │ │ ├── TargetRegistry.h │ │ ├── TargetSelect.h │ │ ├── TaskQueue.h │ │ ├── ThreadLocal.h │ │ ├── ThreadPool.h │ │ ├── Threading.h │ │ ├── TimeProfiler.h │ │ ├── Timer.h │ │ ├── ToolOutputFile.h │ │ ├── TrailingObjects.h │ │ ├── TrigramIndex.h │ │ ├── TypeName.h │ │ ├── TypeSize.h │ │ ├── Unicode.h │ │ ├── UnicodeCharRanges.h │ │ ├── Valgrind.h │ │ ├── VersionTuple.h │ │ ├── VirtualFileSystem.h │ │ ├── Watchdog.h │ │ ├── Win64EH.h │ │ ├── WindowsError.h │ │ ├── WithColor.h │ │ ├── X86DisassemblerDecoderCommon.h │ │ ├── X86TargetParser.def │ │ ├── X86TargetParser.h │ │ ├── YAMLParser.h │ │ ├── YAMLTraits.h │ │ ├── circular_raw_ostream.h │ │ ├── raw_os_ostream.h │ │ ├── raw_ostream.h │ │ ├── raw_sha1_ostream.h │ │ ├── thread.h │ │ ├── type_traits.h │ │ └── xxhash.h │ │ ├── lib │ │ ├── IR │ │ │ ├── AbstractCallSite.cpp │ │ │ ├── AsmWriter.cpp │ │ │ ├── Assumptions.cpp │ │ │ ├── AttributeImpl.h │ │ │ ├── Attributes.cpp │ │ │ ├── AutoUpgrade.cpp │ │ │ ├── BasicBlock.cpp │ │ │ ├── Comdat.cpp │ │ │ ├── ConstantFold.cpp │ │ │ ├── ConstantFold.h │ │ │ ├── ConstantRange.cpp │ │ │ ├── Constants.cpp │ │ │ ├── ConstantsContext.h │ │ │ ├── Core.cpp │ │ │ ├── DIBuilder.cpp │ │ │ ├── DataLayout.cpp │ │ │ ├── DebugInfo.cpp │ │ │ ├── DebugInfoMetadata.cpp │ │ │ ├── DebugLoc.cpp │ │ │ ├── DiagnosticHandler.cpp │ │ │ ├── DiagnosticInfo.cpp │ │ │ ├── DiagnosticPrinter.cpp │ │ │ ├── Dominators.cpp │ │ │ ├── FPEnv.cpp │ │ │ ├── Function.cpp │ │ │ ├── GVMaterializer.cpp │ │ │ ├── GlobalPtrAuthInfo.cpp │ │ │ ├── Globals.cpp │ │ │ ├── IRBuilder.cpp │ │ │ ├── IRPrintingPasses.cpp │ │ │ ├── InlineAsm.cpp │ │ │ ├── Instruction.cpp │ │ │ ├── Instructions.cpp │ │ │ ├── IntrinsicInst.cpp │ │ │ ├── LLVMContext.cpp │ │ │ ├── LLVMContextImpl.cpp │ │ │ ├── LLVMContextImpl.h │ │ │ ├── LLVMRemarkStreamer.cpp │ │ │ ├── LegacyPassManager.cpp │ │ │ ├── MDBuilder.cpp │ │ │ ├── Mangler.cpp │ │ │ ├── Metadata.cpp │ │ │ ├── MetadataImpl.h │ │ │ ├── Module.cpp │ │ │ ├── ModuleSummaryIndex.cpp │ │ │ ├── Operator.cpp │ │ │ ├── OptBisect.cpp │ │ │ ├── Pass.cpp │ │ │ ├── PassInstrumentation.cpp │ │ │ ├── PassManager.cpp │ │ │ ├── PassRegistry.cpp │ │ │ ├── PassTimingInfo.cpp │ │ │ ├── PrintPasses.cpp │ │ │ ├── ProfileSummary.cpp │ │ │ ├── PseudoProbe.cpp │ │ │ ├── SafepointIRVerifier.cpp │ │ │ ├── Statepoint.cpp │ │ │ ├── StructuralHash.cpp │ │ │ ├── SymbolTableListTraitsImpl.h │ │ │ ├── Type.cpp │ │ │ ├── TypeFinder.cpp │ │ │ ├── Use.cpp │ │ │ ├── User.cpp │ │ │ ├── Value.cpp │ │ │ ├── ValueSymbolTable.cpp │ │ │ └── Verifier.cpp │ │ └── Support │ │ │ ├── ABIBreak.cpp │ │ │ ├── AMDGPUMetadata.cpp │ │ │ ├── APFixedPoint.cpp │ │ │ ├── APFloat.cpp │ │ │ ├── APInt.cpp │ │ │ ├── APSInt.cpp │ │ │ ├── ARMAttributeParser.cpp │ │ │ ├── ARMBuildAttrs.cpp │ │ │ ├── ARMTargetParser.cpp │ │ │ ├── ARMWinEH.cpp │ │ │ ├── Allocator.cpp │ │ │ ├── Atomic.cpp │ │ │ ├── BinaryStreamError.cpp │ │ │ ├── BinaryStreamReader.cpp │ │ │ ├── BinaryStreamRef.cpp │ │ │ ├── BinaryStreamWriter.cpp │ │ │ ├── BlockFrequency.cpp │ │ │ ├── BranchProbability.cpp │ │ │ ├── BuryPointer.cpp │ │ │ ├── COM.cpp │ │ │ ├── COPYRIGHT.regex │ │ │ ├── CRC.cpp │ │ │ ├── CachePruning.cpp │ │ │ ├── Chrono.cpp │ │ │ ├── CodeGenCoverage.cpp │ │ │ ├── CommandLine.cpp │ │ │ ├── Compression.cpp │ │ │ ├── ConvertUTF.cpp │ │ │ ├── ConvertUTFWrapper.cpp │ │ │ ├── CrashRecoveryContext.cpp │ │ │ ├── DAGDeltaAlgorithm.cpp │ │ │ ├── DJB.cpp │ │ │ ├── DataExtractor.cpp │ │ │ ├── Debug.cpp │ │ │ ├── DebugCounter.cpp │ │ │ ├── DeltaAlgorithm.cpp │ │ │ ├── DynamicLibrary.cpp │ │ │ ├── ELFAttributeParser.cpp │ │ │ ├── ELFAttributes.cpp │ │ │ ├── Errno.cpp │ │ │ ├── Error.cpp │ │ │ ├── ErrorHandling.cpp │ │ │ ├── ExtensibleRTTI.cpp │ │ │ ├── FileCollector.cpp │ │ │ ├── FileOutputBuffer.cpp │ │ │ ├── FileUtilities.cpp │ │ │ ├── FoldingSet.cpp │ │ │ ├── FormatVariadic.cpp │ │ │ ├── FormattedStream.cpp │ │ │ ├── GlobPattern.cpp │ │ │ ├── GraphWriter.cpp │ │ │ ├── Hashing.cpp │ │ │ ├── Host.cpp │ │ │ ├── InitLLVM.cpp │ │ │ ├── InstructionCost.cpp │ │ │ ├── IntEqClasses.cpp │ │ │ ├── IntervalMap.cpp │ │ │ ├── ItaniumManglingCanonicalizer.cpp │ │ │ ├── JSON.cpp │ │ │ ├── KnownBits.cpp │ │ │ ├── LEB128.cpp │ │ │ ├── LineIterator.cpp │ │ │ ├── Locale.cpp │ │ │ ├── LockFileManager.cpp │ │ │ ├── LowLevelType.cpp │ │ │ ├── MD5.cpp │ │ │ ├── ManagedStatic.cpp │ │ │ ├── MathExtras.cpp │ │ │ ├── MemAlloc.cpp │ │ │ ├── Memory.cpp │ │ │ ├── MemoryBuffer.cpp │ │ │ ├── MemoryBufferRef.cpp │ │ │ ├── NativeFormatting.cpp │ │ │ ├── OptimizedStructLayout.cpp │ │ │ ├── Optional.cpp │ │ │ ├── Parallel.cpp │ │ │ ├── Path.cpp │ │ │ ├── PluginLoader.cpp │ │ │ ├── PrettyStackTrace.cpp │ │ │ ├── Process.cpp │ │ │ ├── Program.cpp │ │ │ ├── RISCVAttributeParser.cpp │ │ │ ├── RISCVAttributes.cpp │ │ │ ├── RWMutex.cpp │ │ │ ├── RandomNumberGenerator.cpp │ │ │ ├── Regex.cpp │ │ │ ├── SHA1.cpp │ │ │ ├── ScaledNumber.cpp │ │ │ ├── ScopedPrinter.cpp │ │ │ ├── Signals.cpp │ │ │ ├── Signposts.cpp │ │ │ ├── SmallPtrSet.cpp │ │ │ ├── SmallVector.cpp │ │ │ ├── SourceMgr.cpp │ │ │ ├── SpecialCaseList.cpp │ │ │ ├── Statistic.cpp │ │ │ ├── StringExtras.cpp │ │ │ ├── StringMap.cpp │ │ │ ├── StringRef.cpp │ │ │ ├── StringSaver.cpp │ │ │ ├── SuffixTree.cpp │ │ │ ├── SymbolRemappingReader.cpp │ │ │ ├── SystemUtils.cpp │ │ │ ├── TarWriter.cpp │ │ │ ├── TargetParser.cpp │ │ │ ├── TargetRegistry.cpp │ │ │ ├── ThreadLocal.cpp │ │ │ ├── ThreadPool.cpp │ │ │ ├── Threading.cpp │ │ │ ├── TimeProfiler.cpp │ │ │ ├── Timer.cpp │ │ │ ├── ToolOutputFile.cpp │ │ │ ├── TrigramIndex.cpp │ │ │ ├── Triple.cpp │ │ │ ├── Twine.cpp │ │ │ ├── Unicode.cpp │ │ │ ├── UnicodeCaseFold.cpp │ │ │ ├── Unix │ │ │ ├── COM.inc │ │ │ ├── DynamicLibrary.inc │ │ │ ├── Host.inc │ │ │ ├── Memory.inc │ │ │ ├── Path.inc │ │ │ ├── Process.inc │ │ │ ├── Program.inc │ │ │ ├── README.txt │ │ │ ├── Signals.inc │ │ │ ├── ThreadLocal.inc │ │ │ ├── Threading.inc │ │ │ ├── Unix.h │ │ │ └── Watchdog.inc │ │ │ ├── Valgrind.cpp │ │ │ ├── VersionTuple.cpp │ │ │ ├── VirtualFileSystem.cpp │ │ │ ├── Watchdog.cpp │ │ │ ├── Windows │ │ │ ├── COM.inc │ │ │ ├── DynamicLibrary.inc │ │ │ ├── Host.inc │ │ │ ├── Memory.inc │ │ │ ├── Path.inc │ │ │ ├── Process.inc │ │ │ ├── Program.inc │ │ │ ├── Signals.inc │ │ │ ├── ThreadLocal.inc │ │ │ ├── Threading.inc │ │ │ ├── Watchdog.inc │ │ │ └── explicit_symbols.inc │ │ │ ├── WithColor.cpp │ │ │ ├── X86TargetParser.cpp │ │ │ ├── YAMLParser.cpp │ │ │ ├── YAMLTraits.cpp │ │ │ ├── Z3Solver.cpp │ │ │ ├── circular_raw_ostream.cpp │ │ │ ├── raw_os_ostream.cpp │ │ │ ├── raw_ostream.cpp │ │ │ ├── regcomp.c │ │ │ ├── regengine.inc │ │ │ ├── regerror.c │ │ │ ├── regex2.h │ │ │ ├── regex_impl.h │ │ │ ├── regexec.c │ │ │ ├── regfree.c │ │ │ ├── regstrlcpy.c │ │ │ ├── regutils.h │ │ │ └── xxhash.cpp │ │ ├── libffi │ │ ├── common │ │ │ ├── include │ │ │ │ ├── ffi.h │ │ │ │ ├── ffi_cfi.h │ │ │ │ ├── ffi_common.h │ │ │ │ ├── fficonfig.h │ │ │ │ └── ffitarget.h │ │ │ └── src │ │ │ │ ├── closures.c │ │ │ │ ├── debug.c │ │ │ │ ├── dlmalloc.c │ │ │ │ ├── java_raw_api.c │ │ │ │ ├── prep_cif.c │ │ │ │ ├── raw_api.c │ │ │ │ └── types.c │ │ └── ios │ │ │ ├── include │ │ │ ├── ffi_arm64.h │ │ │ ├── ffi_armv7.h │ │ │ ├── ffi_i386.h │ │ │ ├── ffi_x86_64.h │ │ │ ├── fficonfig_arm64.h │ │ │ ├── fficonfig_armv7.h │ │ │ ├── fficonfig_i386.h │ │ │ ├── fficonfig_x86_64.h │ │ │ ├── ffitarget_arm64.h │ │ │ ├── ffitarget_armv7.h │ │ │ ├── ffitarget_i386.h │ │ │ └── ffitarget_x86_64.h │ │ │ └── src │ │ │ ├── aarch64 │ │ │ ├── ffi_arm64.c │ │ │ ├── internal.h │ │ │ └── sysv_arm64.S │ │ │ ├── arm │ │ │ ├── ffi_armv7.c │ │ │ ├── internal.h │ │ │ └── sysv_armv7.S │ │ │ └── x86 │ │ │ ├── asmnames.h │ │ │ ├── ffi64_x86_64.c │ │ │ ├── ffi_i386.c │ │ │ ├── ffiw64_x86_64.c │ │ │ ├── internal.h │ │ │ ├── internal64.h │ │ │ ├── sysv_i386.S │ │ │ ├── unix64_x86_64.S │ │ │ └── win64_x86_64.S │ │ └── llvm-c │ │ ├── Analysis.h │ │ ├── BitReader.h │ │ ├── BitWriter.h │ │ ├── Comdat.h │ │ ├── Core.h │ │ ├── DataTypes.h │ │ ├── DebugInfo.h │ │ ├── Disassembler.h │ │ ├── DisassemblerTypes.h │ │ ├── Error.h │ │ ├── ErrorHandling.h │ │ ├── ExecutionEngine.h │ │ ├── ExternC.h │ │ ├── IRReader.h │ │ ├── Initialization.h │ │ ├── LLJIT.h │ │ ├── Linker.h │ │ ├── Object.h │ │ ├── Orc.h │ │ ├── OrcEE.h │ │ ├── Remarks.h │ │ ├── Support.h │ │ ├── Target.h │ │ ├── TargetMachine.h │ │ ├── Transforms │ │ ├── AggressiveInstCombine.h │ │ ├── Coroutines.h │ │ ├── IPO.h │ │ ├── InstCombine.h │ │ ├── PassManagerBuilder.h │ │ ├── Scalar.h │ │ ├── Utils.h │ │ └── Vectorize.h │ │ ├── Types.h │ │ ├── lto.h │ │ └── module.modulemap ├── BitCodeInterpreterUserDemo.cpp ├── Info.plist ├── SceneDelegate.h ├── SceneDelegate.m ├── ViewController.h ├── ViewController.m ├── main.bc └── main.m └── README.md /BitCodeInterpreter.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /BitCodeInterpreter.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /BitCodeInterpreter.xcodeproj/project.xcworkspace/xcuserdata/jintao.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TannerJin/BitCodeInterpreter/c9a73f4dc4f99a9f310e0f88370d9407aa93fa97/BitCodeInterpreter.xcodeproj/project.xcworkspace/xcuserdata/jintao.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /BitCodeInterpreter.xcodeproj/xcuserdata/jintao.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 9 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /BitCodeInterpreter.xcodeproj/xcuserdata/jintao.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | BitCodeInterpreter.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /BitCodeInterpreter/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // BitCodeInterpreter 4 | // 5 | // Created by jintao on 2021/6/24. 6 | // 7 | 8 | #import 9 | 10 | @interface AppDelegate : UIResponder 11 | 12 | 13 | @end 14 | 15 | -------------------------------------------------------------------------------- /BitCodeInterpreter/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // BitCodeInterpreter 4 | // 5 | // Created by jintao on 2021/6/24. 6 | // 7 | 8 | #import "AppDelegate.h" 9 | #import "zlib.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | 24 | #pragma mark - UISceneSession lifecycle 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /BitCodeInterpreter/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /BitCodeInterpreter/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "scale" : "1x", 46 | "size" : "20x20" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "scale" : "2x", 51 | "size" : "20x20" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "scale" : "1x", 56 | "size" : "29x29" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "29x29" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "scale" : "1x", 66 | "size" : "40x40" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "scale" : "2x", 71 | "size" : "40x40" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "scale" : "1x", 76 | "size" : "76x76" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "scale" : "2x", 81 | "size" : "76x76" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "scale" : "2x", 86 | "size" : "83.5x83.5" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "scale" : "1x", 91 | "size" : "1024x1024" 92 | } 93 | ], 94 | "info" : { 95 | "author" : "xcode", 96 | "version" : 1 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /BitCodeInterpreter/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /BitCodeInterpreter/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /BitCodeInterpreter/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/ADT/EnumeratedArray.h: -------------------------------------------------------------------------------- 1 | //===- llvm/ADT/EnumeratedArray.h - Enumerated Array-------------*- C++ -*-===// 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 | // This file defines an array type that can be indexed using scoped enum values. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef LLVM_ADT_ENUMERATEDARRAY_H 14 | #define LLVM_ADT_ENUMERATEDARRAY_H 15 | 16 | #include 17 | 18 | namespace llvm { 19 | 20 | template (LargestEnum)> 23 | class EnumeratedArray { 24 | public: 25 | EnumeratedArray() = default; 26 | EnumeratedArray(ValueType V) { 27 | for (IndexType IX = 0; IX < Size; ++IX) { 28 | Underlying[IX] = V; 29 | } 30 | } 31 | inline const ValueType &operator[](const Enumeration Index) const { 32 | auto IX = static_cast(Index); 33 | assert(IX >= 0 && IX < Size && "Index is out of bounds."); 34 | return Underlying[IX]; 35 | } 36 | inline ValueType &operator[](const Enumeration Index) { 37 | return const_cast( 38 | static_cast &>(*this)[Index]); 40 | } 41 | inline IndexType size() { return Size; } 42 | 43 | private: 44 | ValueType Underlying[Size]; 45 | }; 46 | 47 | } // namespace llvm 48 | 49 | #endif // LLVM_ADT_ENUMERATEDARRAY_H 50 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/ADT/None.h: -------------------------------------------------------------------------------- 1 | //===-- None.h - Simple null value for implicit construction ------*- C++ -*-=// 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 | // This file provides None, an enumerator for use in implicit constructors 10 | // of various (usually templated) types to make such construction more 11 | // terse. 12 | // 13 | //===----------------------------------------------------------------------===// 14 | 15 | #ifndef LLVM_ADT_NONE_H 16 | #define LLVM_ADT_NONE_H 17 | 18 | namespace llvm { 19 | /// A simple null object to allow implicit construction of Optional 20 | /// and similar types without having to spell out the specialization's name. 21 | // (constant value 1 in an attempt to workaround MSVC build issue... ) 22 | enum class NoneType { None = 1 }; 23 | const NoneType None = NoneType::None; 24 | } 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/ADT/StringSet.h: -------------------------------------------------------------------------------- 1 | //===- StringSet.h - An efficient set built on StringMap --------*- C++ -*-===// 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 | // StringSet - A set-like wrapper for the StringMap. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef LLVM_ADT_STRINGSET_H 14 | #define LLVM_ADT_STRINGSET_H 15 | 16 | #include "llvm/ADT/StringMap.h" 17 | 18 | namespace llvm { 19 | 20 | /// StringSet - A wrapper for StringMap that provides set-like functionality. 21 | template 22 | class StringSet : public StringMap { 23 | using Base = StringMap; 24 | 25 | public: 26 | StringSet() = default; 27 | StringSet(std::initializer_list initializer) { 28 | for (StringRef str : initializer) 29 | insert(str); 30 | } 31 | explicit StringSet(AllocatorTy a) : Base(a) {} 32 | 33 | std::pair insert(StringRef key) { 34 | return Base::try_emplace(key); 35 | } 36 | 37 | template 38 | void insert(const InputIt &begin, const InputIt &end) { 39 | for (auto it = begin; it != end; ++it) 40 | insert(*it); 41 | } 42 | 43 | template 44 | std::pair 45 | insert(const StringMapEntry &mapEntry) { 46 | return insert(mapEntry.getKey()); 47 | } 48 | 49 | /// Check if the set contains the given \c key. 50 | bool contains(StringRef key) const { return Base::FindKey(key) != -1; } 51 | }; 52 | 53 | } // end namespace llvm 54 | 55 | #endif // LLVM_ADT_STRINGSET_H 56 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/ADT/ilist_node_base.h: -------------------------------------------------------------------------------- 1 | //===- llvm/ADT/ilist_node_base.h - Intrusive List Node Base -----*- C++ -*-==// 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 | #ifndef LLVM_ADT_ILIST_NODE_BASE_H 10 | #define LLVM_ADT_ILIST_NODE_BASE_H 11 | 12 | #include "llvm/ADT/PointerIntPair.h" 13 | 14 | namespace llvm { 15 | 16 | /// Base class for ilist nodes. 17 | /// 18 | /// Optionally tracks whether this node is the sentinel. 19 | template class ilist_node_base; 20 | 21 | template <> class ilist_node_base { 22 | ilist_node_base *Prev = nullptr; 23 | ilist_node_base *Next = nullptr; 24 | 25 | public: 26 | void setPrev(ilist_node_base *Prev) { this->Prev = Prev; } 27 | void setNext(ilist_node_base *Next) { this->Next = Next; } 28 | ilist_node_base *getPrev() const { return Prev; } 29 | ilist_node_base *getNext() const { return Next; } 30 | 31 | bool isKnownSentinel() const { return false; } 32 | void initializeSentinel() {} 33 | }; 34 | 35 | template <> class ilist_node_base { 36 | PointerIntPair PrevAndSentinel; 37 | ilist_node_base *Next = nullptr; 38 | 39 | public: 40 | void setPrev(ilist_node_base *Prev) { PrevAndSentinel.setPointer(Prev); } 41 | void setNext(ilist_node_base *Next) { this->Next = Next; } 42 | ilist_node_base *getPrev() const { return PrevAndSentinel.getPointer(); } 43 | ilist_node_base *getNext() const { return Next; } 44 | 45 | bool isSentinel() const { return PrevAndSentinel.getInt(); } 46 | bool isKnownSentinel() const { return isSentinel(); } 47 | void initializeSentinel() { PrevAndSentinel.setInt(true); } 48 | }; 49 | 50 | } // end namespace llvm 51 | 52 | #endif // LLVM_ADT_ILIST_NODE_BASE_H 53 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/AsmParser/SlotMapping.h: -------------------------------------------------------------------------------- 1 | //===-- SlotMapping.h - Slot number mapping for unnamed values --*- C++ -*-===// 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 | // This file contains the declaration of the SlotMapping struct. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef LLVM_ASMPARSER_SLOTMAPPING_H 14 | #define LLVM_ASMPARSER_SLOTMAPPING_H 15 | 16 | #include "llvm/ADT/StringMap.h" 17 | #include "llvm/IR/TrackingMDRef.h" 18 | #include 19 | #include 20 | 21 | namespace llvm { 22 | 23 | class GlobalValue; 24 | class Type; 25 | 26 | /// This struct contains the mappings from the slot numbers to unnamed metadata 27 | /// nodes, global values and types. It also contains the mapping for the named 28 | /// types. 29 | /// It can be used to save the parsing state of an LLVM IR module so that the 30 | /// textual references to the values in the module can be parsed outside of the 31 | /// module's source. 32 | struct SlotMapping { 33 | std::vector GlobalValues; 34 | std::map MetadataNodes; 35 | StringMap NamedTypes; 36 | std::map Types; 37 | }; 38 | 39 | } // end namespace llvm 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Bitcode/BitcodeCommon.h: -------------------------------------------------------------------------------- 1 | //===- BitcodeCommon.h - Common code for encode/decode --------*- C++ -*-===// 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 | // This header defines common code to be used by BitcodeWriter and 10 | // BitcodeReader. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_BITCODE_BITCODECOMMON_H 15 | #define LLVM_BITCODE_BITCODECOMMON_H 16 | 17 | #include "llvm/ADT/Bitfields.h" 18 | 19 | namespace llvm { 20 | 21 | struct AllocaPackedValues { 22 | using Align = Bitfield::Element; 23 | using UsedWithInAlloca = Bitfield::Element; 24 | using ExplicitType = Bitfield::Element; 25 | using SwiftError = Bitfield::Element; 26 | }; 27 | 28 | } // namespace llvm 29 | 30 | #endif // LLVM_BITCODE_BITCODECOMMON_H 31 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/CodeGen/IntrinsicLowering.h: -------------------------------------------------------------------------------- 1 | //===-- IntrinsicLowering.h - Intrinsic Function Lowering -------*- C++ -*-===// 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 | // This file defines the IntrinsicLowering interface. This interface allows 10 | // addition of domain-specific or front-end specific intrinsics to LLVM without 11 | // having to modify all of the C backend or interpreter. 12 | // 13 | //===----------------------------------------------------------------------===// 14 | 15 | #ifndef LLVM_CODEGEN_INTRINSICLOWERING_H 16 | #define LLVM_CODEGEN_INTRINSICLOWERING_H 17 | 18 | #include "llvm/IR/Intrinsics.h" 19 | 20 | namespace llvm { 21 | class CallInst; 22 | class DataLayout; 23 | 24 | class IntrinsicLowering { 25 | const DataLayout &DL; 26 | 27 | bool Warned; 28 | 29 | public: 30 | explicit IntrinsicLowering(const DataLayout &DL) : DL(DL), Warned(false) {} 31 | 32 | /// Replace a call to the specified intrinsic function. 33 | /// If an intrinsic function must be implemented by the code generator 34 | /// (such as va_start), this function should print a message and abort. 35 | /// 36 | /// Otherwise, if an intrinsic function call can be lowered, the code to 37 | /// implement it (often a call to a non-intrinsic function) is inserted 38 | /// _after_ the call instruction and the call is deleted. The caller must 39 | /// be capable of handling this kind of change. 40 | void LowerIntrinsicCall(CallInst *CI); 41 | 42 | /// Try to replace a call instruction with a call to a bswap intrinsic. Return 43 | /// false if the call is not a simple integer bswap. 44 | static bool LowerToByteSwap(CallInst *CI); 45 | }; 46 | } 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/DebugInfo/CodeView/CodeViewError.h: -------------------------------------------------------------------------------- 1 | //===- CodeViewError.h - Error extensions for CodeView ----------*- C++ -*-===// 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 | #ifndef LLVM_DEBUGINFO_PDB_CODEVIEW_CODEVIEWERROR_H 10 | #define LLVM_DEBUGINFO_PDB_CODEVIEW_CODEVIEWERROR_H 11 | 12 | #include "llvm/Support/Error.h" 13 | 14 | #include 15 | 16 | namespace llvm { 17 | namespace codeview { 18 | enum class cv_error_code { 19 | unspecified = 1, 20 | insufficient_buffer, 21 | operation_unsupported, 22 | corrupt_record, 23 | no_records, 24 | unknown_member_record, 25 | }; 26 | } // namespace codeview 27 | } // namespace llvm 28 | 29 | namespace std { 30 | template <> 31 | struct is_error_code_enum : std::true_type {}; 32 | } // namespace std 33 | 34 | namespace llvm { 35 | namespace codeview { 36 | const std::error_category &CVErrorCategory(); 37 | 38 | inline std::error_code make_error_code(cv_error_code E) { 39 | return std::error_code(static_cast(E), CVErrorCategory()); 40 | } 41 | 42 | /// Base class for errors originating when parsing raw PDB files 43 | class CodeViewError : public ErrorInfo { 44 | public: 45 | using ErrorInfo::ErrorInfo; // inherit constructors 47 | CodeViewError(const Twine &S) : ErrorInfo(S, cv_error_code::unspecified) {} 48 | static char ID; 49 | }; 50 | 51 | } // namespace codeview 52 | } // namespace llvm 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Demangle/Demangle.cpp: -------------------------------------------------------------------------------- 1 | //===-- Demangle.cpp - Common demangling functions ------------------------===// 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 | /// \file This file contains definitions of common demangling functions. 10 | /// 11 | //===----------------------------------------------------------------------===// 12 | 13 | #include "llvm/Demangle/Demangle.h" 14 | #include 15 | 16 | static bool isItaniumEncoding(const std::string &MangledName) { 17 | size_t Pos = MangledName.find_first_not_of('_'); 18 | // A valid Itanium encoding requires 1-4 leading underscores, followed by 'Z'. 19 | return Pos > 0 && Pos <= 4 && MangledName[Pos] == 'Z'; 20 | } 21 | 22 | std::string llvm::demangle(const std::string &MangledName) { 23 | char *Demangled; 24 | if (isItaniumEncoding(MangledName)) 25 | Demangled = itaniumDemangle(MangledName.c_str(), nullptr, nullptr, nullptr); 26 | else 27 | Demangled = microsoftDemangle(MangledName.c_str(), nullptr, nullptr, 28 | nullptr, nullptr); 29 | 30 | if (!Demangled) 31 | return MangledName; 32 | 33 | std::string Ret = Demangled; 34 | std::free(Demangled); 35 | return Ret; 36 | } 37 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/ExecutionEngine/GenericValue.h: -------------------------------------------------------------------------------- 1 | //===- GenericValue.h - Represent any type of LLVM value --------*- C++ -*-===// 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 | // The GenericValue class is used to represent an LLVM value of arbitrary type. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef LLVM_EXECUTIONENGINE_GENERICVALUE_H 14 | #define LLVM_EXECUTIONENGINE_GENERICVALUE_H 15 | 16 | #include "llvm/ADT/APInt.h" 17 | #include 18 | 19 | namespace llvm { 20 | 21 | using PointerTy = void *; 22 | 23 | struct GenericValue { 24 | struct IntPair { 25 | unsigned int first; 26 | unsigned int second; 27 | }; 28 | union { 29 | double DoubleVal; 30 | float FloatVal; 31 | PointerTy PointerVal; 32 | struct IntPair UIntPairVal; 33 | unsigned char Untyped[8]; 34 | }; 35 | APInt IntVal; // also used for long doubles. 36 | // For aggregate data types. 37 | std::vector AggregateVal; 38 | 39 | // to make code faster, set GenericValue to zero could be omitted, but it is 40 | // potentially can cause problems, since GenericValue to store garbage 41 | // instead of zero. 42 | GenericValue() : IntVal(1, 0) { 43 | UIntPairVal.first = 0; 44 | UIntPairVal.second = 0; 45 | } 46 | explicit GenericValue(void *V) : PointerVal(V), IntVal(1, 0) {} 47 | }; 48 | 49 | inline GenericValue PTOGV(void *P) { return GenericValue(P); } 50 | inline void *GVTOP(const GenericValue &GV) { return GV.PointerVal; } 51 | 52 | } // end namespace llvm 53 | 54 | #endif // LLVM_EXECUTIONENGINE_GENERICVALUE_H 55 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/ExecutionEngine/ObjectCache.h: -------------------------------------------------------------------------------- 1 | //===-- ObjectCache.h - Class definition for the ObjectCache ----*- C++ -*-===// 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 | #ifndef LLVM_EXECUTIONENGINE_OBJECTCACHE_H 10 | #define LLVM_EXECUTIONENGINE_OBJECTCACHE_H 11 | 12 | #include 13 | 14 | namespace llvm { 15 | 16 | class MemoryBuffer; 17 | class MemoryBufferRef; 18 | class Module; 19 | 20 | /// This is the base ObjectCache type which can be provided to an 21 | /// ExecutionEngine for the purpose of avoiding compilation for Modules that 22 | /// have already been compiled and an object file is available. 23 | class ObjectCache { 24 | virtual void anchor(); 25 | 26 | public: 27 | ObjectCache() = default; 28 | 29 | virtual ~ObjectCache() = default; 30 | 31 | /// notifyObjectCompiled - Provides a pointer to compiled code for Module M. 32 | virtual void notifyObjectCompiled(const Module *M, MemoryBufferRef Obj) = 0; 33 | 34 | /// Returns a pointer to a newly allocated MemoryBuffer that contains the 35 | /// object which corresponds with Module M, or 0 if an object is not 36 | /// available. 37 | virtual std::unique_ptr getObject(const Module* M) = 0; 38 | }; 39 | 40 | } // end namespace llvm 41 | 42 | #endif // LLVM_EXECUTIONENGINE_OBJECTCACHE_H 43 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/ExecutionEngine/OrcV1Deprecation.h: -------------------------------------------------------------------------------- 1 | //===------ OrcV1Deprecation.h - Memory manager for MC-JIT ------*- C++ -*-===// 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 | // Tag for suppressing ORCv1 deprecation warnings. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef LLVM_EXECUTIONENGINE_ORCV1DEPRECATION_H 14 | #define LLVM_EXECUTIONENGINE_ORCV1DEPRECATION_H 15 | 16 | namespace llvm { 17 | 18 | enum ORCv1DeprecationAcknowledgement { AcknowledgeORCv1Deprecation }; 19 | 20 | } // namespace llvm 21 | 22 | #endif // LLVM_EXECUTIONENGINE_ORCV1DEPRECATION_H 23 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/IR/Assumptions.h: -------------------------------------------------------------------------------- 1 | //===--- Assumptions.h - Assumption handling and organization ---*- C++ -*-===// 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 | // String assumptions that are known to optimization passes should be placed in 10 | // the KnownAssumptionStrings set. This can be done in various ways, i.a., 11 | // via a static KnownAssumptionString object. 12 | // 13 | //===----------------------------------------------------------------------===// 14 | 15 | #ifndef LLVM_IR_ASSUMPTIONS_H 16 | #define LLVM_IR_ASSUMPTIONS_H 17 | 18 | #include "llvm/ADT/StringRef.h" 19 | #include "llvm/ADT/StringSet.h" 20 | 21 | namespace llvm { 22 | 23 | class Function; 24 | 25 | /// The key we use for assumption attributes. 26 | constexpr StringRef AssumptionAttrKey = "llvm.assume"; 27 | 28 | /// A set of known assumption strings that are accepted without warning and 29 | /// which can be recommended as typo correction. 30 | extern StringSet<> KnownAssumptionStrings; 31 | 32 | /// Helper that allows to insert a new assumption string in the known assumption 33 | /// set by creating a (static) object. 34 | struct KnownAssumptionString { 35 | KnownAssumptionString(StringRef AssumptionStr) 36 | : AssumptionStr(AssumptionStr) { 37 | KnownAssumptionStrings.insert(AssumptionStr); 38 | } 39 | operator StringRef() const { return AssumptionStr; } 40 | 41 | private: 42 | StringRef AssumptionStr; 43 | }; 44 | 45 | /// Return true if \p F has the assumption \p AssumptionStr attached. 46 | bool hasAssumption(Function &F, const KnownAssumptionString &AssumptionStr); 47 | 48 | } // namespace llvm 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/IR/DerivedUser.h: -------------------------------------------------------------------------------- 1 | //===- DerivedUser.h - Base for non-IR Users --------------------*- C++ -*-===// 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 | #ifndef LLVM_IR_DERIVEDUSER_H 10 | #define LLVM_IR_DERIVEDUSER_H 11 | 12 | #include "llvm/IR/User.h" 13 | 14 | namespace llvm { 15 | 16 | class Type; 17 | class Use; 18 | 19 | /// Extension point for the Value hierarchy. All classes outside of lib/IR 20 | /// that wish to inherit from User should instead inherit from DerivedUser 21 | /// instead. Inheriting from this class is discouraged. 22 | /// 23 | /// Generally speaking, Value is the base of a closed class hierarchy 24 | /// that can't be extended by code outside of lib/IR. This class creates a 25 | /// loophole that allows classes outside of lib/IR to extend User to leverage 26 | /// its use/def list machinery. 27 | class DerivedUser : public User { 28 | protected: 29 | using DeleteValueTy = void (*)(DerivedUser *); 30 | 31 | private: 32 | friend class Value; 33 | 34 | DeleteValueTy DeleteValue; 35 | 36 | public: 37 | DerivedUser(Type *Ty, unsigned VK, Use *U, unsigned NumOps, 38 | DeleteValueTy DeleteValue) 39 | : User(Ty, VK, U, NumOps), DeleteValue(DeleteValue) {} 40 | }; 41 | 42 | } // end namespace llvm 43 | 44 | #endif // LLVM_IR_DERIVEDUSER_H 45 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/IR/GVMaterializer.h: -------------------------------------------------------------------------------- 1 | //===- GVMaterializer.h - Interface for GV materializers --------*- C++ -*-===// 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 | // This file provides an abstract interface for loading a module from some 10 | // place. This interface allows incremental or random access loading of 11 | // functions from the file. This is useful for applications like JIT compilers 12 | // or interprocedural optimizers that do not need the entire program in memory 13 | // at the same time. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | 17 | #ifndef LLVM_IR_GVMATERIALIZER_H 18 | #define LLVM_IR_GVMATERIALIZER_H 19 | 20 | #include 21 | 22 | namespace llvm { 23 | 24 | class Error; 25 | class GlobalValue; 26 | class StructType; 27 | 28 | class GVMaterializer { 29 | protected: 30 | GVMaterializer() = default; 31 | 32 | public: 33 | virtual ~GVMaterializer(); 34 | 35 | /// Make sure the given GlobalValue is fully read. 36 | /// 37 | virtual Error materialize(GlobalValue *GV) = 0; 38 | 39 | /// Make sure the entire Module has been completely read. 40 | /// 41 | virtual Error materializeModule() = 0; 42 | 43 | virtual Error materializeMetadata() = 0; 44 | virtual void setStripDebugInfo() = 0; 45 | 46 | virtual std::vector getIdentifiedStructTypes() const = 0; 47 | }; 48 | 49 | } // end namespace llvm 50 | 51 | #endif // LLVM_IR_GVMATERIALIZER_H 52 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/IR/IntrinsicsBPF.h: -------------------------------------------------------------------------------- 1 | /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ 2 | |* *| 3 | |* Intrinsic Function Source Fragment *| 4 | |* *| 5 | |* Automatically generated file, do not edit! *| 6 | |* *| 7 | \*===----------------------------------------------------------------------===*/ 8 | 9 | #ifndef LLVM_IR_INTRINSIC_BPF_ENUMS_H 10 | #define LLVM_IR_INTRINSIC_BPF_ENUMS_H 11 | 12 | namespace llvm { 13 | namespace Intrinsic { 14 | enum BPFIntrinsics : unsigned { 15 | // Enum values for intrinsics 16 | bpf_btf_type_id = 2347, // llvm.bpf.btf.type.id 17 | bpf_load_byte, // llvm.bpf.load.byte 18 | bpf_load_half, // llvm.bpf.load.half 19 | bpf_load_word, // llvm.bpf.load.word 20 | bpf_passthrough, // llvm.bpf.passthrough 21 | bpf_preserve_enum_value, // llvm.bpf.preserve.enum.value 22 | bpf_preserve_field_info, // llvm.bpf.preserve.field.info 23 | bpf_preserve_type_info, // llvm.bpf.preserve.type.info 24 | bpf_pseudo, // llvm.bpf.pseudo 25 | }; // enum 26 | } // namespace Intrinsic 27 | } // namespace llvm 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/IR/PrintPasses.h: -------------------------------------------------------------------------------- 1 | //===- PrintPasses.h - Determining whether/when to print IR ---------------===// 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 | #ifndef LLVM_IR_PRINTPASSES_H 10 | #define LLVM_IR_PRINTPASSES_H 11 | 12 | #include "llvm/ADT/StringRef.h" 13 | #include 14 | 15 | namespace llvm { 16 | 17 | // Returns true if printing before/after some pass is enabled, whether all 18 | // passes or a specific pass. 19 | bool shouldPrintBeforeSomePass(); 20 | bool shouldPrintAfterSomePass(); 21 | 22 | // Returns true if we should print before/after a specific pass. The argument 23 | // should be the pass ID, e.g. "instcombine". 24 | bool shouldPrintBeforePass(StringRef PassID); 25 | bool shouldPrintAfterPass(StringRef PassID); 26 | 27 | // Returns true if we should print before/after all passes. 28 | bool shouldPrintBeforeAll(); 29 | bool shouldPrintAfterAll(); 30 | 31 | // The list of passes to print before/after, if we only want to print 32 | // before/after specific passes. 33 | std::vector printBeforePasses(); 34 | std::vector printAfterPasses(); 35 | 36 | // Returns true if we should always print the entire module. 37 | bool forcePrintModuleIR(); 38 | 39 | // Returns true if we should print the function. 40 | bool isFunctionInPrintList(StringRef FunctionName); 41 | 42 | } // namespace llvm 43 | 44 | #endif // LLVM_IR_PRINTPASSES_H 45 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/IR/SafepointIRVerifier.h: -------------------------------------------------------------------------------- 1 | //===- SafepointIRVerifier.h - Checks for GC relocation problems *- C++ -*-===// 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 | // This file defines a verifier which is useful for enforcing the relocation 10 | // properties required by a relocating GC. Specifically, it looks for uses of 11 | // the unrelocated value of pointer SSA values after a possible safepoint. It 12 | // attempts to report no false negatives, but may end up reporting false 13 | // positives in rare cases (see the note at the top of the corresponding cpp 14 | // file.) 15 | // 16 | //===----------------------------------------------------------------------===// 17 | 18 | #ifndef LLVM_IR_SAFEPOINT_IR_VERIFIER 19 | #define LLVM_IR_SAFEPOINT_IR_VERIFIER 20 | 21 | #include "llvm/IR/PassManager.h" 22 | 23 | namespace llvm { 24 | 25 | class Function; 26 | class FunctionPass; 27 | 28 | /// Run the safepoint verifier over a single function. Crashes on failure. 29 | void verifySafepointIR(Function &F); 30 | 31 | /// Create an instance of the safepoint verifier pass which can be added to 32 | /// a pass pipeline to check for relocation bugs. 33 | FunctionPass *createSafepointIRVerifierPass(); 34 | 35 | /// Create an instance of the safepoint verifier pass which can be added to 36 | /// a pass pipeline to check for relocation bugs. 37 | class SafepointIRVerifierPass : public PassInfoMixin { 38 | 39 | public: 40 | explicit SafepointIRVerifierPass() {} 41 | 42 | PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); 43 | }; 44 | } 45 | 46 | #endif // LLVM_IR_SAFEPOINT_IR_VERIFIER 47 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/IR/StructuralHash.h: -------------------------------------------------------------------------------- 1 | //===- llvm/IR/StructuralHash.h - IR Hash for expensive checks --*- C++ -*-===// 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 | // This file provides hashing of the LLVM IR structure to be used to check 10 | // Passes modification status. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_IR_STRUCTURALHASH_H 15 | #define LLVM_IR_STRUCTURALHASH_H 16 | 17 | #ifdef EXPENSIVE_CHECKS 18 | 19 | #include 20 | 21 | // This header is only meant to be used when -DEXPENSIVE_CHECKS is set 22 | namespace llvm { 23 | 24 | class Function; 25 | class Module; 26 | 27 | uint64_t StructuralHash(const Function &F); 28 | uint64_t StructuralHash(const Module &M); 29 | 30 | } // end namespace llvm 31 | 32 | #endif 33 | 34 | #endif // LLVM_IR_STRUCTURALHASH_H 35 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/IR/UseListOrder.h: -------------------------------------------------------------------------------- 1 | //===- llvm/IR/UseListOrder.h - LLVM Use List Order -------------*- C++ -*-===// 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 | // This file has structures and command-line options for preserving use-list 10 | // order. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_IR_USELISTORDER_H 15 | #define LLVM_IR_USELISTORDER_H 16 | 17 | #include 18 | #include 19 | 20 | namespace llvm { 21 | 22 | class Function; 23 | class Value; 24 | 25 | /// Structure to hold a use-list order. 26 | struct UseListOrder { 27 | const Value *V = nullptr; 28 | const Function *F = nullptr; 29 | std::vector Shuffle; 30 | 31 | UseListOrder(const Value *V, const Function *F, size_t ShuffleSize) 32 | : V(V), F(F), Shuffle(ShuffleSize) {} 33 | 34 | UseListOrder() = default; 35 | UseListOrder(UseListOrder &&) = default; 36 | UseListOrder &operator=(UseListOrder &&) = default; 37 | }; 38 | 39 | using UseListOrderStack = std::vector; 40 | 41 | } // end namespace llvm 42 | 43 | #endif // LLVM_IR_USELISTORDER_H 44 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/MC/MCCodeEmitter.cpp: -------------------------------------------------------------------------------- 1 | //===- MCCodeEmitter.cpp - Instruction Encoding ---------------------------===// 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/MC/MCCodeEmitter.h" 10 | 11 | using namespace llvm; 12 | 13 | MCCodeEmitter::MCCodeEmitter() = default; 14 | 15 | MCCodeEmitter::~MCCodeEmitter() = default; 16 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/MC/MCCodeEmitter.h: -------------------------------------------------------------------------------- 1 | //===- llvm/MC/MCCodeEmitter.h - Instruction Encoding -----------*- C++ -*-===// 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 | #ifndef LLVM_MC_MCCODEEMITTER_H 10 | #define LLVM_MC_MCCODEEMITTER_H 11 | 12 | namespace llvm { 13 | 14 | class MCFixup; 15 | class MCInst; 16 | class MCSubtargetInfo; 17 | class raw_ostream; 18 | template class SmallVectorImpl; 19 | 20 | /// MCCodeEmitter - Generic instruction encoding interface. 21 | class MCCodeEmitter { 22 | protected: // Can only create subclasses. 23 | MCCodeEmitter(); 24 | 25 | public: 26 | MCCodeEmitter(const MCCodeEmitter &) = delete; 27 | MCCodeEmitter &operator=(const MCCodeEmitter &) = delete; 28 | virtual ~MCCodeEmitter(); 29 | 30 | /// Lifetime management 31 | virtual void reset() {} 32 | 33 | /// Emit the prefixes of given instruction on the output stream. 34 | /// 35 | /// \param Inst a single low-level machine instruction. 36 | /// \param OS output stream. 37 | virtual void emitPrefix(const MCInst &Inst, raw_ostream &OS, 38 | const MCSubtargetInfo &STI) const {} 39 | /// EncodeInstruction - Encode the given \p Inst to bytes on the output 40 | /// stream \p OS. 41 | virtual void encodeInstruction(const MCInst &Inst, raw_ostream &OS, 42 | SmallVectorImpl &Fixups, 43 | const MCSubtargetInfo &STI) const = 0; 44 | }; 45 | 46 | } // end namespace llvm 47 | 48 | #endif // LLVM_MC_MCCODEEMITTER_H 49 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/MC/MCFixedLenDisassembler.h: -------------------------------------------------------------------------------- 1 | //===-- llvm/MC/MCFixedLenDisassembler.h - Decoder driver -------*- C++ -*-===// 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 | // Fixed length disassembler decoder state machine driver. 9 | //===----------------------------------------------------------------------===// 10 | #ifndef LLVM_MC_MCFIXEDLENDISASSEMBLER_H 11 | #define LLVM_MC_MCFIXEDLENDISASSEMBLER_H 12 | 13 | namespace llvm { 14 | 15 | namespace MCD { 16 | // Disassembler state machine opcodes. 17 | enum DecoderOps { 18 | OPC_ExtractField = 1, // OPC_ExtractField(uint8_t Start, uint8_t Len) 19 | OPC_FilterValue, // OPC_FilterValue(uleb128 Val, uint16_t NumToSkip) 20 | OPC_CheckField, // OPC_CheckField(uint8_t Start, uint8_t Len, 21 | // uleb128 Val, uint16_t NumToSkip) 22 | OPC_CheckPredicate, // OPC_CheckPredicate(uleb128 PIdx, uint16_t NumToSkip) 23 | OPC_Decode, // OPC_Decode(uleb128 Opcode, uleb128 DIdx) 24 | OPC_TryDecode, // OPC_TryDecode(uleb128 Opcode, uleb128 DIdx, 25 | // uint16_t NumToSkip) 26 | OPC_SoftFail, // OPC_SoftFail(uleb128 PMask, uleb128 NMask) 27 | OPC_Fail // OPC_Fail() 28 | }; 29 | 30 | } // namespace MCDecode 31 | } // namespace llvm 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/MC/MCFixupKindInfo.h: -------------------------------------------------------------------------------- 1 | //===-- llvm/MC/MCFixupKindInfo.h - Fixup Descriptors -----------*- C++ -*-===// 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 | #ifndef LLVM_MC_MCFIXUPKINDINFO_H 10 | #define LLVM_MC_MCFIXUPKINDINFO_H 11 | 12 | namespace llvm { 13 | 14 | /// Target independent information on a fixup kind. 15 | struct MCFixupKindInfo { 16 | enum FixupKindFlags { 17 | /// Is this fixup kind PCrelative? This is used by the assembler backend to 18 | /// evaluate fixup values in a target independent manner when possible. 19 | FKF_IsPCRel = (1 << 0), 20 | 21 | /// Should this fixup kind force a 4-byte aligned effective PC value? 22 | FKF_IsAlignedDownTo32Bits = (1 << 1), 23 | 24 | /// Should this fixup be evaluated in a target dependent manner? 25 | FKF_IsTarget = (1 << 2), 26 | 27 | /// This fixup kind should be resolved if defined. 28 | /// FIXME This is a workaround because we don't support certain ARM 29 | /// relocation types. This flag should eventually be removed. 30 | FKF_Constant = 1 << 3, 31 | }; 32 | 33 | /// A target specific name for the fixup kind. The names will be unique for 34 | /// distinct kinds on any given target. 35 | const char *Name; 36 | 37 | /// The bit offset to write the relocation into. 38 | unsigned TargetOffset; 39 | 40 | /// The number of bits written by this fixup. The bits are assumed to be 41 | /// contiguous. 42 | unsigned TargetSize; 43 | 44 | /// Flags describing additional information on this fixup kind. 45 | unsigned Flags; 46 | }; 47 | 48 | } // End llvm namespace 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/MC/MCInstBuilder.h: -------------------------------------------------------------------------------- 1 | //===-- llvm/MC/MCInstBuilder.h - Simplify creation of MCInsts --*- C++ -*-===// 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 | // This file contains the MCInstBuilder class for convenient creation of 10 | // MCInsts. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_MC_MCINSTBUILDER_H 15 | #define LLVM_MC_MCINSTBUILDER_H 16 | 17 | #include "llvm/MC/MCInst.h" 18 | 19 | namespace llvm { 20 | 21 | class MCInstBuilder { 22 | MCInst Inst; 23 | 24 | public: 25 | /// Create a new MCInstBuilder for an MCInst with a specific opcode. 26 | MCInstBuilder(unsigned Opcode) { 27 | Inst.setOpcode(Opcode); 28 | } 29 | 30 | /// Add a new register operand. 31 | MCInstBuilder &addReg(unsigned Reg) { 32 | Inst.addOperand(MCOperand::createReg(Reg)); 33 | return *this; 34 | } 35 | 36 | /// Add a new integer immediate operand. 37 | MCInstBuilder &addImm(int64_t Val) { 38 | Inst.addOperand(MCOperand::createImm(Val)); 39 | return *this; 40 | } 41 | 42 | /// Add a new floating point immediate operand. 43 | MCInstBuilder &addFPImm(double Val) { 44 | Inst.addOperand(MCOperand::createFPImm(Val)); 45 | return *this; 46 | } 47 | 48 | /// Add a new MCExpr operand. 49 | MCInstBuilder &addExpr(const MCExpr *Val) { 50 | Inst.addOperand(MCOperand::createExpr(Val)); 51 | return *this; 52 | } 53 | 54 | /// Add a new MCInst operand. 55 | MCInstBuilder &addInst(const MCInst *Val) { 56 | Inst.addOperand(MCOperand::createInst(Val)); 57 | return *this; 58 | } 59 | 60 | /// Add an operand. 61 | MCInstBuilder &addOperand(const MCOperand &Op) { 62 | Inst.addOperand(Op); 63 | return *this; 64 | } 65 | 66 | operator MCInst&() { 67 | return Inst; 68 | } 69 | }; 70 | 71 | } // end namespace llvm 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/MC/MCInstrAnalysis.cpp: -------------------------------------------------------------------------------- 1 | //===- MCInstrAnalysis.cpp - InstrDesc target hooks -----------------------===// 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/MC/MCInstrAnalysis.h" 10 | 11 | #include "llvm/ADT/APInt.h" 12 | #include "llvm/MC/MCInst.h" 13 | #include "llvm/MC/MCInstrDesc.h" 14 | #include "llvm/MC/MCInstrInfo.h" 15 | #include 16 | 17 | using namespace llvm; 18 | 19 | bool MCInstrAnalysis::clearsSuperRegisters(const MCRegisterInfo &MRI, 20 | const MCInst &Inst, 21 | APInt &Writes) const { 22 | Writes.clearAllBits(); 23 | return false; 24 | } 25 | 26 | bool MCInstrAnalysis::evaluateBranch(const MCInst & /*Inst*/, uint64_t /*Addr*/, 27 | uint64_t /*Size*/, 28 | uint64_t & /*Target*/) const { 29 | return false; 30 | } 31 | 32 | Optional 33 | MCInstrAnalysis::evaluateMemoryOperandAddress(const MCInst &Inst, uint64_t Addr, 34 | uint64_t Size) const { 35 | return None; 36 | } 37 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/MC/MCInstrInfo.cpp: -------------------------------------------------------------------------------- 1 | //===- lib/MC/MCInstrInfo.cpp - Target Instruction Info -------------------===// 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/MC/MCInstrInfo.h" 10 | #include "llvm/MC/MCInst.h" 11 | #include "llvm/MC/MCSubtargetInfo.h" 12 | 13 | using namespace llvm; 14 | 15 | bool MCInstrInfo::getDeprecatedInfo(MCInst &MI, const MCSubtargetInfo &STI, 16 | std::string &Info) const { 17 | unsigned Opcode = MI.getOpcode(); 18 | if (ComplexDeprecationInfos && ComplexDeprecationInfos[Opcode]) 19 | return ComplexDeprecationInfos[Opcode](MI, STI, Info); 20 | if (DeprecatedFeatures && DeprecatedFeatures[Opcode] != uint8_t(-1U) && 21 | STI.getFeatureBits()[DeprecatedFeatures[Opcode]]) { 22 | // FIXME: it would be nice to include the subtarget feature here. 23 | Info = "deprecated"; 24 | return true; 25 | } 26 | return false; 27 | } 28 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/MC/MCLabel.cpp: -------------------------------------------------------------------------------- 1 | //===- lib/MC/MCLabel.cpp - MCLabel implementation ------------------------===// 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/MC/MCLabel.h" 10 | #include "llvm/Config/llvm-config.h" 11 | #include "llvm/Support/Compiler.h" 12 | #include "llvm/Support/Debug.h" 13 | #include "llvm/Support/raw_ostream.h" 14 | 15 | using namespace llvm; 16 | 17 | void MCLabel::print(raw_ostream &OS) const { 18 | OS << '"' << getInstance() << '"'; 19 | } 20 | 21 | #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 22 | LLVM_DUMP_METHOD void MCLabel::dump() const { 23 | print(dbgs()); 24 | } 25 | #endif 26 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/MC/MCLabel.h: -------------------------------------------------------------------------------- 1 | //===- MCLabel.h - Machine Code Directional Local Labels --------*- C++ -*-===// 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 | // This file contains the declaration of the MCLabel class. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef LLVM_MC_MCLABEL_H 14 | #define LLVM_MC_MCLABEL_H 15 | 16 | namespace llvm { 17 | 18 | class raw_ostream; 19 | 20 | /// Instances of this class represent a label name in the MC file, 21 | /// and MCLabel are created and uniqued by the MCContext class. MCLabel 22 | /// should only be constructed for valid instances in the object file. 23 | class MCLabel { 24 | // The instance number of this Directional Local Label. 25 | unsigned Instance; 26 | 27 | private: // MCContext creates and uniques these. 28 | friend class MCContext; 29 | 30 | MCLabel(unsigned instance) : Instance(instance) {} 31 | 32 | public: 33 | MCLabel(const MCLabel &) = delete; 34 | MCLabel &operator=(const MCLabel &) = delete; 35 | 36 | /// Get the current instance of this Directional Local Label. 37 | unsigned getInstance() const { return Instance; } 38 | 39 | /// Increment the current instance of this Directional Local Label. 40 | unsigned incInstance() { return ++Instance; } 41 | 42 | /// Print the value to the stream \p OS. 43 | void print(raw_ostream &OS) const; 44 | 45 | /// Print the value to stderr. 46 | void dump() const; 47 | }; 48 | 49 | inline raw_ostream &operator<<(raw_ostream &OS, const MCLabel &Label) { 50 | Label.print(OS); 51 | return OS; 52 | } 53 | 54 | } // end namespace llvm 55 | 56 | #endif // LLVM_MC_MCLABEL_H 57 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/MC/MCMachObjectTargetWriter.cpp: -------------------------------------------------------------------------------- 1 | //===- MCMachObjectTargetWriter.cpp - Mach-O Target Writer Subclass -------===// 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/MC/MCMachObjectWriter.h" 10 | 11 | using namespace llvm; 12 | 13 | MCMachObjectTargetWriter::MCMachObjectTargetWriter(bool Is64Bit_, 14 | uint32_t CPUType_, 15 | uint32_t CPUSubtype_) 16 | : Is64Bit(Is64Bit_), CPUType(CPUType_), CPUSubtype(CPUSubtype_) {} 17 | 18 | MCMachObjectTargetWriter::~MCMachObjectTargetWriter() = default; 19 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/MC/MCNullStreamer.cpp: -------------------------------------------------------------------------------- 1 | //===- lib/MC/MCNullStreamer.cpp - Dummy Streamer Implementation ----------===// 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/ADT/StringRef.h" 10 | #include "llvm/MC/MCInst.h" 11 | #include "llvm/MC/MCStreamer.h" 12 | #include "llvm/MC/MCSymbol.h" 13 | 14 | using namespace llvm; 15 | 16 | namespace { 17 | 18 | class MCNullStreamer : public MCStreamer { 19 | public: 20 | MCNullStreamer(MCContext &Context) : MCStreamer(Context) {} 21 | 22 | /// @name MCStreamer Interface 23 | /// @{ 24 | 25 | bool hasRawTextSupport() const override { return true; } 26 | void emitRawTextImpl(StringRef String) override {} 27 | 28 | bool emitSymbolAttribute(MCSymbol *Symbol, 29 | MCSymbolAttr Attribute) override { 30 | return true; 31 | } 32 | 33 | void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, 34 | unsigned ByteAlignment) override {} 35 | void emitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr, 36 | uint64_t Size = 0, unsigned ByteAlignment = 0, 37 | SMLoc Loc = SMLoc()) override {} 38 | void emitGPRel32Value(const MCExpr *Value) override {} 39 | }; 40 | 41 | } 42 | 43 | MCStreamer *llvm::createNullStreamer(MCContext &Context) { 44 | return new MCNullStreamer(Context); 45 | } 46 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/MC/MCObjectWriter.cpp: -------------------------------------------------------------------------------- 1 | //===- lib/MC/MCObjectWriter.cpp - MCObjectWriter implementation ----------===// 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/MC/MCObjectWriter.h" 10 | #include "llvm/MC/MCAssembler.h" 11 | #include "llvm/MC/MCExpr.h" 12 | #include "llvm/MC/MCFragment.h" 13 | #include "llvm/MC/MCSymbol.h" 14 | 15 | using namespace llvm; 16 | 17 | MCObjectWriter::~MCObjectWriter() = default; 18 | 19 | bool MCObjectWriter::isSymbolRefDifferenceFullyResolved( 20 | const MCAssembler &Asm, const MCSymbolRefExpr *A, const MCSymbolRefExpr *B, 21 | bool InSet) const { 22 | // Modified symbol references cannot be resolved. 23 | if (A->getKind() != MCSymbolRefExpr::VK_None || 24 | B->getKind() != MCSymbolRefExpr::VK_None) 25 | return false; 26 | 27 | const MCSymbol &SA = A->getSymbol(); 28 | const MCSymbol &SB = B->getSymbol(); 29 | if (SA.isUndefined() || SB.isUndefined()) 30 | return false; 31 | 32 | if (!SA.getFragment() || !SB.getFragment()) 33 | return false; 34 | 35 | return isSymbolRefDifferenceFullyResolvedImpl(Asm, SA, SB, InSet); 36 | } 37 | 38 | bool MCObjectWriter::isSymbolRefDifferenceFullyResolvedImpl( 39 | const MCAssembler &Asm, const MCSymbol &A, const MCSymbol &B, 40 | bool InSet) const { 41 | return isSymbolRefDifferenceFullyResolvedImpl(Asm, A, *B.getFragment(), InSet, 42 | false); 43 | } 44 | 45 | bool MCObjectWriter::isSymbolRefDifferenceFullyResolvedImpl( 46 | const MCAssembler &Asm, const MCSymbol &SymA, const MCFragment &FB, 47 | bool InSet, bool IsPCRel) const { 48 | const MCSection &SecA = SymA.getSection(); 49 | const MCSection &SecB = *FB.getParent(); 50 | // On ELF and COFF A - B is absolute if A and B are in the same section. 51 | return &SecA == &SecB; 52 | } 53 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/MC/MCParser/AsmCond.h: -------------------------------------------------------------------------------- 1 | //===- AsmCond.h - Assembly file conditional assembly ----------*- C++ -*-===// 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 | #ifndef LLVM_MC_MCPARSER_ASMCOND_H 10 | #define LLVM_MC_MCPARSER_ASMCOND_H 11 | 12 | namespace llvm { 13 | 14 | /// AsmCond - Class to support conditional assembly 15 | /// 16 | /// The conditional assembly feature (.if, .else, .elseif and .endif) is 17 | /// implemented with AsmCond that tells us what we are in the middle of 18 | /// processing. Ignore can be either true or false. When true we are ignoring 19 | /// the block of code in the middle of a conditional. 20 | 21 | class AsmCond { 22 | public: 23 | enum ConditionalAssemblyType { 24 | NoCond, // no conditional is being processed 25 | IfCond, // inside if conditional 26 | ElseIfCond, // inside elseif conditional 27 | ElseCond // inside else conditional 28 | }; 29 | 30 | ConditionalAssemblyType TheCond = NoCond; 31 | bool CondMet = false; 32 | bool Ignore = false; 33 | }; 34 | 35 | } // end namespace llvm 36 | 37 | #endif // LLVM_MC_MCPARSER_ASMCOND_H 38 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/MC/MCParser/MCAsmParserUtils.h: -------------------------------------------------------------------------------- 1 | //===- llvm/MC/MCAsmParserUtils.h - Asm Parser Utilities --------*- C++ -*-===// 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 | #ifndef LLVM_MC_MCPARSER_MCASMPARSERUTILS_H 10 | #define LLVM_MC_MCPARSER_MCASMPARSERUTILS_H 11 | 12 | namespace llvm { 13 | 14 | class MCAsmParser; 15 | class MCExpr; 16 | class MCSymbol; 17 | class StringRef; 18 | 19 | namespace MCParserUtils { 20 | 21 | /// Parse a value expression and return whether it can be assigned to a symbol 22 | /// with the given name. 23 | /// 24 | /// On success, returns false and sets the Symbol and Value output parameters. 25 | bool parseAssignmentExpression(StringRef Name, bool allow_redef, 26 | MCAsmParser &Parser, MCSymbol *&Symbol, 27 | const MCExpr *&Value); 28 | 29 | } // namespace MCParserUtils 30 | 31 | } // namespace llvm 32 | 33 | #endif // LLVM_MC_MCPARSER_MCASMPARSERUTILS_H 34 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/MC/MCParser/MCTargetAsmParser.cpp: -------------------------------------------------------------------------------- 1 | //===-- MCTargetAsmParser.cpp - Target Assembly Parser --------------------===// 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/MC/MCParser/MCTargetAsmParser.h" 10 | #include "llvm/MC/MCContext.h" 11 | 12 | using namespace llvm; 13 | 14 | MCTargetAsmParser::MCTargetAsmParser(MCTargetOptions const &MCOptions, 15 | const MCSubtargetInfo &STI, 16 | const MCInstrInfo &MII) 17 | : MCOptions(MCOptions), STI(&STI), MII(MII) {} 18 | 19 | MCTargetAsmParser::~MCTargetAsmParser() = default; 20 | 21 | MCSubtargetInfo &MCTargetAsmParser::copySTI() { 22 | MCSubtargetInfo &STICopy = getContext().getSubtargetCopy(getSTI()); 23 | STI = &STICopy; 24 | return STICopy; 25 | } 26 | 27 | const MCSubtargetInfo &MCTargetAsmParser::getSTI() const { 28 | return *STI; 29 | } 30 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/MC/MCTargetOptions.cpp: -------------------------------------------------------------------------------- 1 | //===- lib/MC/MCTargetOptions.cpp - MC Target Options ---------------------===// 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/MC/MCTargetOptions.h" 10 | #include "llvm/ADT/StringRef.h" 11 | 12 | using namespace llvm; 13 | 14 | MCTargetOptions::MCTargetOptions() 15 | : MCRelaxAll(false), MCNoExecStack(false), MCFatalWarnings(false), 16 | MCNoWarn(false), MCNoDeprecatedWarn(false), MCSaveTempLabels(false), 17 | MCUseDwarfDirectory(false), MCIncrementalLinkerCompatible(false), 18 | ShowMCEncoding(false), ShowMCInst(false), AsmVerbose(false), 19 | PreserveAsmComments(true), Dwarf64(false) {} 20 | 21 | StringRef MCTargetOptions::getABIName() const { 22 | return ABIName; 23 | } 24 | 25 | StringRef MCTargetOptions::getAssemblyLanguage() const { 26 | return AssemblyLanguage; 27 | } 28 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/MC/MCTargetOptionsCommandFlags.h: -------------------------------------------------------------------------------- 1 | //===-- MCTargetOptionsCommandFlags.h --------------------------*- C++ -*-===// 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 | // This file contains machine code-specific flags that are shared between 10 | // different command line tools. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_MC_MCTARGETOPTIONSCOMMANDFLAGS_H 15 | #define LLVM_MC_MCTARGETOPTIONSCOMMANDFLAGS_H 16 | 17 | #include "llvm/ADT/Optional.h" 18 | #include 19 | 20 | namespace llvm { 21 | 22 | class MCTargetOptions; 23 | 24 | namespace mc { 25 | 26 | bool getRelaxAll(); 27 | Optional getExplicitRelaxAll(); 28 | 29 | bool getIncrementalLinkerCompatible(); 30 | 31 | int getDwarfVersion(); 32 | 33 | bool getDwarf64(); 34 | 35 | bool getShowMCInst(); 36 | 37 | bool getFatalWarnings(); 38 | 39 | bool getNoWarn(); 40 | 41 | bool getNoDeprecatedWarn(); 42 | 43 | std::string getABIName(); 44 | 45 | /// Create this object with static storage to register mc-related command 46 | /// line options. 47 | struct RegisterMCTargetOptionsFlags { 48 | RegisterMCTargetOptionsFlags(); 49 | }; 50 | 51 | MCTargetOptions InitMCTargetOptionsFromFlags(); 52 | 53 | } // namespace mc 54 | 55 | } // namespace llvm 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/MC/MCValue.cpp: -------------------------------------------------------------------------------- 1 | //===- lib/MC/MCValue.cpp - MCValue implementation ------------------------===// 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/MC/MCValue.h" 10 | #include "llvm/Config/llvm-config.h" 11 | #include "llvm/MC/MCExpr.h" 12 | #include "llvm/Support/Debug.h" 13 | #include "llvm/Support/ErrorHandling.h" 14 | #include "llvm/Support/raw_ostream.h" 15 | 16 | using namespace llvm; 17 | 18 | void MCValue::print(raw_ostream &OS) const { 19 | if (isAbsolute()) { 20 | OS << getConstant(); 21 | return; 22 | } 23 | 24 | // FIXME: prints as a number, which isn't ideal. But the meaning will be 25 | // target-specific anyway. 26 | if (getRefKind()) 27 | OS << ':' << getRefKind() << ':'; 28 | 29 | OS << *getSymA(); 30 | 31 | if (getSymB()) { 32 | OS << " - "; 33 | OS << *getSymB(); 34 | } 35 | 36 | if (getConstant()) 37 | OS << " + " << getConstant(); 38 | } 39 | 40 | #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 41 | LLVM_DUMP_METHOD void MCValue::dump() const { 42 | print(dbgs()); 43 | } 44 | #endif 45 | 46 | MCSymbolRefExpr::VariantKind MCValue::getAccessVariant() const { 47 | const MCSymbolRefExpr *B = getSymB(); 48 | if (B) { 49 | if (B->getKind() != MCSymbolRefExpr::VK_None) 50 | llvm_unreachable("unsupported"); 51 | } 52 | 53 | const MCSymbolRefExpr *A = getSymA(); 54 | if (!A) 55 | return MCSymbolRefExpr::VK_None; 56 | 57 | return A->getKind(); 58 | } 59 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Object/ArchiveWriter.h: -------------------------------------------------------------------------------- 1 | //===- ArchiveWriter.h - ar archive file format writer ----------*- C++ -*-===// 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 | // Declares the writeArchive function for writing an archive file. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef LLVM_OBJECT_ARCHIVEWRITER_H 14 | #define LLVM_OBJECT_ARCHIVEWRITER_H 15 | 16 | #include "llvm/Object/Archive.h" 17 | 18 | namespace llvm { 19 | 20 | struct NewArchiveMember { 21 | std::unique_ptr Buf; 22 | StringRef MemberName; 23 | sys::TimePoint ModTime; 24 | unsigned UID = 0, GID = 0, Perms = 0644; 25 | 26 | NewArchiveMember() = default; 27 | NewArchiveMember(MemoryBufferRef BufRef); 28 | 29 | static Expected 30 | getOldMember(const object::Archive::Child &OldMember, bool Deterministic); 31 | 32 | static Expected getFile(StringRef FileName, 33 | bool Deterministic); 34 | }; 35 | 36 | Expected computeArchiveRelativePath(StringRef From, StringRef To); 37 | 38 | Error writeArchive(StringRef ArcName, ArrayRef NewMembers, 39 | bool WriteSymtab, object::Archive::Kind Kind, 40 | bool Deterministic, bool Thin, 41 | std::unique_ptr OldArchiveBuf = nullptr); 42 | 43 | // writeArchiveToBuffer is similar to writeArchive but returns the Archive in a 44 | // buffer instead of writing it out to a file. 45 | Expected> 46 | writeArchiveToBuffer(ArrayRef NewMembers, bool WriteSymtab, 47 | object::Archive::Kind Kind, bool Deterministic, bool Thin); 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Object/CVDebugRecord.h: -------------------------------------------------------------------------------- 1 | //===- CVDebugRecord.h ------------------------------------------*- C++ -*-===// 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 | #ifndef LLVM_OBJECT_CVDEBUGRECORD_H 10 | #define LLVM_OBJECT_CVDEBUGRECORD_H 11 | 12 | #include "llvm/Support/Endian.h" 13 | 14 | namespace llvm { 15 | namespace OMF { 16 | struct Signature { 17 | enum ID : uint32_t { 18 | PDB70 = 0x53445352, // RSDS 19 | PDB20 = 0x3031424e, // NB10 20 | CV50 = 0x3131424e, // NB11 21 | CV41 = 0x3930424e, // NB09 22 | }; 23 | 24 | support::ulittle32_t CVSignature; 25 | support::ulittle32_t Offset; 26 | }; 27 | } 28 | 29 | namespace codeview { 30 | struct PDB70DebugInfo { 31 | support::ulittle32_t CVSignature; 32 | uint8_t Signature[16]; 33 | support::ulittle32_t Age; 34 | // char PDBFileName[]; 35 | }; 36 | 37 | struct PDB20DebugInfo { 38 | support::ulittle32_t CVSignature; 39 | support::ulittle32_t Offset; 40 | support::ulittle32_t Signature; 41 | support::ulittle32_t Age; 42 | // char PDBFileName[]; 43 | }; 44 | 45 | union DebugInfo { 46 | struct OMF::Signature Signature; 47 | struct PDB20DebugInfo PDB20; 48 | struct PDB70DebugInfo PDB70; 49 | }; 50 | } 51 | } 52 | 53 | #endif 54 | 55 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Remarks/RemarkFormat.cpp: -------------------------------------------------------------------------------- 1 | //===- RemarkFormat.cpp --------------------------------------------------===// 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 | // Implementation of utilities to handle the different remark formats. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #include "llvm/Remarks/RemarkFormat.h" 14 | #include "llvm/ADT/StringSwitch.h" 15 | #include "llvm/Remarks/BitstreamRemarkContainer.h" 16 | 17 | using namespace llvm; 18 | using namespace llvm::remarks; 19 | 20 | Expected llvm::remarks::parseFormat(StringRef FormatStr) { 21 | auto Result = StringSwitch(FormatStr) 22 | .Cases("", "yaml", Format::YAML) 23 | .Case("yaml-strtab", Format::YAMLStrTab) 24 | .Case("bitstream", Format::Bitstream) 25 | .Default(Format::Unknown); 26 | 27 | if (Result == Format::Unknown) 28 | return createStringError(std::make_error_code(std::errc::invalid_argument), 29 | "Unknown remark format: '%s'", 30 | FormatStr.data()); 31 | 32 | return Result; 33 | } 34 | 35 | Expected llvm::remarks::magicToFormat(StringRef MagicStr) { 36 | auto Result = 37 | StringSwitch(MagicStr) 38 | .StartsWith("--- ", Format::YAML) // This is only an assumption. 39 | .StartsWith(remarks::Magic, Format::YAMLStrTab) 40 | .StartsWith(remarks::ContainerMagic, Format::Bitstream) 41 | .Default(Format::Unknown); 42 | 43 | if (Result == Format::Unknown) 44 | return createStringError(std::make_error_code(std::errc::invalid_argument), 45 | "Unknown remark magic: '%s'", MagicStr.data()); 46 | return Result; 47 | } 48 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Remarks/RemarkFormat.h: -------------------------------------------------------------------------------- 1 | //===-- llvm/Remarks/RemarkFormat.h - The format of remarks -----*- C++/-*-===// 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 | // This file defines utilities to deal with the format of remarks. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef LLVM_REMARKS_REMARK_FORMAT_H 14 | #define LLVM_REMARKS_REMARK_FORMAT_H 15 | 16 | #include "llvm/ADT/StringRef.h" 17 | #include "llvm/Support/Error.h" 18 | 19 | namespace llvm { 20 | namespace remarks { 21 | 22 | constexpr StringLiteral Magic("REMARKS"); 23 | 24 | /// The format used for serializing/deserializing remarks. 25 | enum class Format { Unknown, YAML, YAMLStrTab, Bitstream }; 26 | 27 | /// Parse and validate a string for the remark format. 28 | Expected parseFormat(StringRef FormatStr); 29 | 30 | /// Parse and validate a magic number to a remark format. 31 | Expected magicToFormat(StringRef Magic); 32 | 33 | } // end namespace remarks 34 | } // end namespace llvm 35 | 36 | #endif /* LLVM_REMARKS_REMARK_FORMAT_H */ 37 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/AlignOf.h: -------------------------------------------------------------------------------- 1 | //===--- AlignOf.h - Portable calculation of type alignment -----*- C++ -*-===// 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 | // This file defines the AlignedCharArrayUnion class. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef LLVM_SUPPORT_ALIGNOF_H 14 | #define LLVM_SUPPORT_ALIGNOF_H 15 | 16 | #include 17 | 18 | namespace llvm { 19 | 20 | /// A suitably aligned and sized character array member which can hold elements 21 | /// of any type. 22 | /// 23 | /// This template is equivalent to std::aligned_union_t<1, ...>, but we cannot 24 | /// use it due to a bug in the MSVC x86 compiler: 25 | /// https://github.com/microsoft/STL/issues/1533 26 | /// Using `alignas` here works around the bug. 27 | template struct AlignedCharArrayUnion { 28 | using AlignedUnion = std::aligned_union_t<1, T, Ts...>; 29 | alignas(alignof(AlignedUnion)) char buffer[sizeof(AlignedUnion)]; 30 | }; 31 | 32 | } // end namespace llvm 33 | 34 | #endif // LLVM_SUPPORT_ALIGNOF_H 35 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/Atomic.h: -------------------------------------------------------------------------------- 1 | //===- llvm/Support/Atomic.h - Atomic Operations -----------------*- C++ -*-===// 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 | // This file declares the llvm::sys atomic operations. 10 | // 11 | // DO NOT USE IN NEW CODE! 12 | // 13 | // New code should always rely on the std::atomic facilities in C++11. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | 17 | #ifndef LLVM_SUPPORT_ATOMIC_H 18 | #define LLVM_SUPPORT_ATOMIC_H 19 | 20 | #include "llvm/Support/DataTypes.h" 21 | #include "_types/_uint32_t.h" 22 | 23 | // Windows will at times define MemoryFence. 24 | #ifdef MemoryFence 25 | #undef MemoryFence 26 | #endif 27 | 28 | namespace llvm { 29 | namespace sys { 30 | void MemoryFence(); 31 | 32 | #ifdef _MSC_VER 33 | typedef long cas_flag; 34 | #else 35 | typedef uint32_t cas_flag; 36 | #endif 37 | cas_flag CompareAndSwap(volatile cas_flag* ptr, 38 | cas_flag new_value, 39 | cas_flag old_value); 40 | } 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/Base64.h: -------------------------------------------------------------------------------- 1 | //===--- Base64.h - Base64 Encoder/Decoder ----------------------*- C++ -*-===// 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 | // This file provides generic base64 encoder/decoder. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef LLVM_SUPPORT_BASE64_H 14 | #define LLVM_SUPPORT_BASE64_H 15 | 16 | #include 17 | 18 | namespace llvm { 19 | 20 | template std::string encodeBase64(InputBytes const &Bytes) { 21 | static const char Table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 22 | "abcdefghijklmnopqrstuvwxyz" 23 | "0123456789+/"; 24 | std::string Buffer; 25 | Buffer.resize(((Bytes.size() + 2) / 3) * 4); 26 | 27 | size_t i = 0, j = 0; 28 | for (size_t n = Bytes.size() / 3 * 3; i < n; i += 3, j += 4) { 29 | uint32_t x = ((unsigned char)Bytes[i] << 16) | 30 | ((unsigned char)Bytes[i + 1] << 8) | 31 | (unsigned char)Bytes[i + 2]; 32 | Buffer[j + 0] = Table[(x >> 18) & 63]; 33 | Buffer[j + 1] = Table[(x >> 12) & 63]; 34 | Buffer[j + 2] = Table[(x >> 6) & 63]; 35 | Buffer[j + 3] = Table[x & 63]; 36 | } 37 | if (i + 1 == Bytes.size()) { 38 | uint32_t x = ((unsigned char)Bytes[i] << 16); 39 | Buffer[j + 0] = Table[(x >> 18) & 63]; 40 | Buffer[j + 1] = Table[(x >> 12) & 63]; 41 | Buffer[j + 2] = '='; 42 | Buffer[j + 3] = '='; 43 | } else if (i + 2 == Bytes.size()) { 44 | uint32_t x = 45 | ((unsigned char)Bytes[i] << 16) | ((unsigned char)Bytes[i + 1] << 8); 46 | Buffer[j + 0] = Table[(x >> 18) & 63]; 47 | Buffer[j + 1] = Table[(x >> 12) & 63]; 48 | Buffer[j + 2] = Table[(x >> 6) & 63]; 49 | Buffer[j + 3] = '='; 50 | } 51 | return Buffer; 52 | } 53 | 54 | } // end namespace llvm 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/BinaryStreamError.h: -------------------------------------------------------------------------------- 1 | //===- BinaryStreamError.h - Error extensions for Binary Streams *- C++ -*-===// 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 | #ifndef LLVM_SUPPORT_BINARYSTREAMERROR_H 10 | #define LLVM_SUPPORT_BINARYSTREAMERROR_H 11 | 12 | #include "llvm/ADT/StringRef.h" 13 | #include "llvm/Support/Error.h" 14 | 15 | #include 16 | 17 | namespace llvm { 18 | enum class stream_error_code { 19 | unspecified, 20 | stream_too_short, 21 | invalid_array_size, 22 | invalid_offset, 23 | filesystem_error 24 | }; 25 | 26 | /// Base class for errors originating when parsing raw PDB files 27 | class BinaryStreamError : public ErrorInfo { 28 | public: 29 | static char ID; 30 | explicit BinaryStreamError(stream_error_code C); 31 | explicit BinaryStreamError(StringRef Context); 32 | BinaryStreamError(stream_error_code C, StringRef Context); 33 | 34 | void log(raw_ostream &OS) const override; 35 | std::error_code convertToErrorCode() const override; 36 | 37 | StringRef getErrorMessage() const; 38 | 39 | stream_error_code getErrorCode() const { return Code; } 40 | 41 | private: 42 | std::string ErrMsg; 43 | stream_error_code Code; 44 | }; 45 | } // namespace llvm 46 | 47 | #endif // LLVM_SUPPORT_BINARYSTREAMERROR_H 48 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/BuryPointer.h: -------------------------------------------------------------------------------- 1 | //===- llvm/Support/BuryPointer.h - Memory Manipulation/Leak ----*- C++ -*-===// 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 | #ifndef LLVM_SUPPORT_BURYPOINTER_H 10 | #define LLVM_SUPPORT_BURYPOINTER_H 11 | 12 | #include 13 | 14 | namespace llvm { 15 | 16 | // In tools that will exit soon anyway, going through the process of explicitly 17 | // deallocating resources can be unnecessary - better to leak the resources and 18 | // let the OS clean them up when the process ends. Use this function to ensure 19 | // the memory is not misdiagnosed as an unintentional leak by leak detection 20 | // tools (this is achieved by preserving pointers to the object in a globally 21 | // visible array). 22 | void BuryPointer(const void *Ptr); 23 | template void BuryPointer(std::unique_ptr Ptr) { 24 | BuryPointer(Ptr.release()); 25 | } 26 | 27 | } // namespace llvm 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/CBindingWrapping.h: -------------------------------------------------------------------------------- 1 | //===- llvm/Support/CBindingWrapping.h - C Interface Wrapping ---*- C++ -*-===// 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 | // This file declares the wrapping macros for the C interface. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef LLVM_SUPPORT_CBINDINGWRAPPING_H 14 | #define LLVM_SUPPORT_CBINDINGWRAPPING_H 15 | 16 | #include "llvm-c/Types.h" 17 | #include "llvm/Support/Casting.h" 18 | 19 | #define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \ 20 | inline ty *unwrap(ref P) { \ 21 | return reinterpret_cast(P); \ 22 | } \ 23 | \ 24 | inline ref wrap(const ty *P) { \ 25 | return reinterpret_cast(const_cast(P)); \ 26 | } 27 | 28 | #define DEFINE_ISA_CONVERSION_FUNCTIONS(ty, ref) \ 29 | DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \ 30 | \ 31 | template \ 32 | inline T *unwrap(ref P) { \ 33 | return cast(unwrap(P)); \ 34 | } 35 | 36 | #define DEFINE_STDCXX_CONVERSION_FUNCTIONS(ty, ref) \ 37 | DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \ 38 | \ 39 | template \ 40 | inline T *unwrap(ref P) { \ 41 | T *Q = (T*)unwrap(P); \ 42 | assert(Q && "Invalid cast!"); \ 43 | return Q; \ 44 | } 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/COM.h: -------------------------------------------------------------------------------- 1 | //===- llvm/Support/COM.h ---------------------------------------*- C++ -*-===// 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 | /// \file 9 | /// 10 | /// Provides a library for accessing COM functionality of the Host OS. 11 | /// 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_SUPPORT_COM_H 15 | #define LLVM_SUPPORT_COM_H 16 | 17 | namespace llvm { 18 | namespace sys { 19 | 20 | enum class COMThreadingMode { SingleThreaded, MultiThreaded }; 21 | 22 | class InitializeCOMRAII { 23 | public: 24 | explicit InitializeCOMRAII(COMThreadingMode Threading, 25 | bool SpeedOverMemory = false); 26 | ~InitializeCOMRAII(); 27 | 28 | private: 29 | InitializeCOMRAII(const InitializeCOMRAII &) = delete; 30 | void operator=(const InitializeCOMRAII &) = delete; 31 | }; 32 | } 33 | } 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/CRC.h: -------------------------------------------------------------------------------- 1 | //===-- llvm/Support/CRC.h - Cyclic Redundancy Check-------------*- C++ -*-===// 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 | // This file contains implementations of CRC functions. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef LLVM_SUPPORT_CRC_H 14 | #define LLVM_SUPPORT_CRC_H 15 | 16 | #include "llvm/Support/DataTypes.h" 17 | #include "_types/_uint32_t.h" 18 | #include "_types/_uint8_t.h" 19 | 20 | namespace llvm { 21 | template class ArrayRef; 22 | 23 | // Compute the CRC-32 of Data. 24 | uint32_t crc32(ArrayRef Data); 25 | 26 | // Compute the running CRC-32 of Data, with CRC being the previous value of the 27 | // checksum. 28 | uint32_t crc32(uint32_t CRC, ArrayRef Data); 29 | 30 | // Class for computing the JamCRC. 31 | // 32 | // We will use the "Rocksoft^tm Model CRC Algorithm" to describe the properties 33 | // of this CRC: 34 | // Width : 32 35 | // Poly : 04C11DB7 36 | // Init : FFFFFFFF 37 | // RefIn : True 38 | // RefOut : True 39 | // XorOut : 00000000 40 | // Check : 340BC6D9 (result of CRC for "123456789") 41 | // 42 | // In other words, this is the same as CRC-32, except that XorOut is 0 instead 43 | // of FFFFFFFF. 44 | // 45 | // N.B. We permit flexibility of the "Init" value. Some consumers of this need 46 | // it to be zero. 47 | class JamCRC { 48 | public: 49 | JamCRC(uint32_t Init = 0xFFFFFFFFU) : CRC(Init) {} 50 | 51 | // Update the CRC calculation with Data. 52 | void update(ArrayRef Data); 53 | 54 | uint32_t getCRC() const { return CRC; } 55 | 56 | private: 57 | uint32_t CRC; 58 | }; 59 | 60 | } // end namespace llvm 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/Capacity.h: -------------------------------------------------------------------------------- 1 | //===--- Capacity.h - Generic computation of ADT memory use -----*- C++ -*-===// 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 | // This file defines the capacity function that computes the amount of 10 | // memory used by an ADT. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_SUPPORT_CAPACITY_H 15 | #define LLVM_SUPPORT_CAPACITY_H 16 | 17 | #include 18 | 19 | namespace llvm { 20 | 21 | template 22 | static inline size_t capacity_in_bytes(const T &x) { 23 | // This default definition of capacity should work for things like std::vector 24 | // and friends. More specialized versions will work for others. 25 | return x.capacity() * sizeof(typename T::value_type); 26 | } 27 | 28 | } // end namespace llvm 29 | 30 | #endif 31 | 32 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/CodeGenCoverage.h: -------------------------------------------------------------------------------- 1 | //== llvm/Support/CodeGenCoverage.h ------------------------------*- C++ -*-==// 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 | /// \file This file provides rule coverage tracking for tablegen-erated CodeGen. 9 | //===----------------------------------------------------------------------===// 10 | 11 | #ifndef LLVM_SUPPORT_CODEGENCOVERAGE_H 12 | #define LLVM_SUPPORT_CODEGENCOVERAGE_H 13 | 14 | #include "llvm/ADT/BitVector.h" 15 | 16 | namespace llvm { 17 | class LLVMContext; 18 | class MemoryBuffer; 19 | 20 | class CodeGenCoverage { 21 | protected: 22 | BitVector RuleCoverage; 23 | 24 | public: 25 | using const_covered_iterator = BitVector::const_set_bits_iterator; 26 | 27 | CodeGenCoverage(); 28 | 29 | void setCovered(uint64_t RuleID); 30 | bool isCovered(uint64_t RuleID) const; 31 | iterator_range covered() const; 32 | 33 | bool parse(MemoryBuffer &Buffer, StringRef BackendName); 34 | bool emit(StringRef FilePrefix, StringRef BackendName) const; 35 | void reset(); 36 | }; 37 | } // namespace llvm 38 | 39 | #endif // ifndef LLVM_SUPPORT_CODEGENCOVERAGE_H 40 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/Compression.h: -------------------------------------------------------------------------------- 1 | //===-- llvm/Support/Compression.h ---Compression----------------*- C++ -*-===// 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 | // This file contains basic functions for compression/uncompression. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef LLVM_SUPPORT_COMPRESSION_H 14 | #define LLVM_SUPPORT_COMPRESSION_H 15 | 16 | #include "llvm/Support/DataTypes.h" 17 | #include "stddef.h" 18 | #include "_types/_uint32_t.h" 19 | 20 | namespace llvm { 21 | template class SmallVectorImpl; 22 | class Error; 23 | class StringRef; 24 | 25 | namespace zlib { 26 | 27 | static constexpr int NoCompression = 0; 28 | static constexpr int BestSpeedCompression = 1; 29 | static constexpr int DefaultCompression = 6; 30 | static constexpr int BestSizeCompression = 9; 31 | 32 | bool isAvailable(); 33 | 34 | Error compress(StringRef InputBuffer, SmallVectorImpl &CompressedBuffer, 35 | int Level = DefaultCompression); 36 | 37 | Error uncompress(StringRef InputBuffer, char *UncompressedBuffer, 38 | size_t &UncompressedSize); 39 | 40 | Error uncompress(StringRef InputBuffer, 41 | SmallVectorImpl &UncompressedBuffer, 42 | size_t UncompressedSize); 43 | 44 | uint32_t crc32(StringRef Buffer); 45 | 46 | } // End of namespace zlib 47 | 48 | } // End of namespace llvm 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/DJB.h: -------------------------------------------------------------------------------- 1 | //===-- llvm/Support/DJB.h ---DJB Hash --------------------------*- C++ -*-===// 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 | // This file contains support for the DJ Bernstein hash function. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef LLVM_SUPPORT_DJB_H 14 | #define LLVM_SUPPORT_DJB_H 15 | 16 | #include "llvm/ADT/StringRef.h" 17 | 18 | namespace llvm { 19 | 20 | /// The Bernstein hash function used by the DWARF accelerator tables. 21 | inline uint32_t djbHash(StringRef Buffer, uint32_t H = 5381) { 22 | for (unsigned char C : Buffer.bytes()) 23 | H = (H << 5) + H + C; 24 | return H; 25 | } 26 | 27 | /// Computes the Bernstein hash after folding the input according to the Dwarf 5 28 | /// standard case folding rules. 29 | uint32_t caseFoldingDjbHash(StringRef Buffer, uint32_t H = 5381); 30 | } // namespace llvm 31 | 32 | #endif // LLVM_SUPPORT_DJB_H 33 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/DataTypes.h: -------------------------------------------------------------------------------- 1 | //===-- llvm/Support/DataTypes.h - Define fixed size types ------*- C++ -*-===// 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 | // Due to layering constraints (Support depends on llvm-c) this is a thin 10 | // wrapper around the implementation that lives in llvm-c, though most clients 11 | // can/should think of this as being provided by Support for simplicity (not 12 | // many clients are aware of their dependency on llvm-c). 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | //#include "llvm-c/DataTypes.h" 17 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/ELFAttributes.h: -------------------------------------------------------------------------------- 1 | //===-- ELFAttributes.h - ELF Attributes ------------------------*- C++ -*-===// 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 | #ifndef LLVM_SUPPORT_ELFATTRIBUTES_H 10 | #define LLVM_SUPPORT_ELFATTRIBUTES_H 11 | 12 | #include "llvm/ADT/ArrayRef.h" 13 | #include "llvm/ADT/StringRef.h" 14 | 15 | namespace llvm { 16 | 17 | struct TagNameItem { 18 | unsigned attr; 19 | StringRef tagName; 20 | }; 21 | 22 | using TagNameMap = ArrayRef; 23 | 24 | namespace ELFAttrs { 25 | 26 | enum AttrType : unsigned { File = 1, Section = 2, Symbol = 3 }; 27 | 28 | StringRef attrTypeAsString(unsigned attr, TagNameMap tagNameMap, 29 | bool hasTagPrefix = true); 30 | Optional attrTypeFromString(StringRef tag, TagNameMap tagNameMap); 31 | 32 | // Magic numbers for ELF attributes. 33 | enum AttrMagic { Format_Version = 0x41 }; 34 | 35 | } // namespace ELFAttrs 36 | } // namespace llvm 37 | #endif 38 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/Errno.h: -------------------------------------------------------------------------------- 1 | //===- llvm/Support/Errno.h - Portable+convenient errno handling -*- C++ -*-===// 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 | // This file declares some portable and convenient functions to deal with errno. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef LLVM_SUPPORT_ERRNO_H 14 | #define LLVM_SUPPORT_ERRNO_H 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | namespace llvm { 21 | namespace sys { 22 | 23 | /// Returns a string representation of the errno value, using whatever 24 | /// thread-safe variant of strerror() is available. Be sure to call this 25 | /// immediately after the function that set errno, or errno may have been 26 | /// overwritten by an intervening call. 27 | std::string StrError(); 28 | 29 | /// Like the no-argument version above, but uses \p errnum instead of errno. 30 | std::string StrError(int errnum); 31 | 32 | template 33 | inline decltype(auto) RetryAfterSignal(const FailT &Fail, const Fun &F, 34 | const Args &... As) { 35 | decltype(F(As...)) Res; 36 | do { 37 | errno = 0; 38 | Res = F(As...); 39 | } while (Res == Fail && errno == EINTR); 40 | return Res; 41 | } 42 | 43 | } // namespace sys 44 | } // namespace llvm 45 | 46 | #endif // LLVM_SYSTEM_ERRNO_H 47 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/ExitCodes.h: -------------------------------------------------------------------------------- 1 | //===-- llvm/Support/ExitCodes.h - Exit codes for exit() -------*- C++ -*-===// 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 | /// \file 10 | /// This file contains definitions of exit codes for exit() function. They are 11 | /// either defined by sysexits.h if it is supported, or defined here if 12 | /// sysexits.h is not supported. 13 | /// 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef LLVM_SUPPORT_EXITCODES_H 17 | #define LLVM_SUPPORT_EXITCODES_H 18 | 19 | #include "llvm/Config/llvm-config.h" 20 | 21 | #if HAVE_SYSEXITS_H 22 | #include 23 | #elif __MVS__ 24 | // does not exist on z/OS. The only value used in LLVM is 25 | // EX_IOERR, which is used to signal a special error condition (broken pipe). 26 | // Define the macro with its usual value from BSD systems, which is chosen to 27 | // not clash with more standard exit codes like 1. 28 | #define EX_IOERR 74 29 | #elif LLVM_ON_UNIX 30 | //#error Exit code EX_IOERR not available 31 | #define EX_IOERR 75 32 | #endif 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/FileSystem/UniqueID.h: -------------------------------------------------------------------------------- 1 | //===- llvm/Support/FileSystem/UniqueID.h - UniqueID for files --*- C++ -*-===// 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 | // This file is cut out of llvm/Support/FileSystem.h to allow UniqueID to be 10 | // reused without bloating the includes. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_SUPPORT_FILESYSTEM_UNIQUEID_H 15 | #define LLVM_SUPPORT_FILESYSTEM_UNIQUEID_H 16 | 17 | #include 18 | 19 | namespace llvm { 20 | namespace sys { 21 | namespace fs { 22 | 23 | class UniqueID { 24 | uint64_t Device; 25 | uint64_t File; 26 | 27 | public: 28 | UniqueID() = default; 29 | UniqueID(uint64_t Device, uint64_t File) : Device(Device), File(File) {} 30 | 31 | bool operator==(const UniqueID &Other) const { 32 | return Device == Other.Device && File == Other.File; 33 | } 34 | bool operator!=(const UniqueID &Other) const { return !(*this == Other); } 35 | bool operator<(const UniqueID &Other) const { 36 | /// Don't use std::tie since it bloats the compile time of this header. 37 | if (Device < Other.Device) 38 | return true; 39 | if (Other.Device < Device) 40 | return false; 41 | return File < Other.File; 42 | } 43 | 44 | uint64_t getDevice() const { return Device; } 45 | uint64_t getFile() const { return File; } 46 | }; 47 | 48 | } // end namespace fs 49 | } // end namespace sys 50 | } // end namespace llvm 51 | 52 | #endif // LLVM_SUPPORT_FILESYSTEM_UNIQUEID_H 53 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/GlobPattern.h: -------------------------------------------------------------------------------- 1 | //===-- GlobPattern.h - glob pattern matcher implementation -*- C++ -*-----===// 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 | // This file implements a glob pattern matcher. The glob pattern is the 10 | // rule used by the shell. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_SUPPORT_GLOB_PATTERN_H 15 | #define LLVM_SUPPORT_GLOB_PATTERN_H 16 | 17 | #include "llvm/ADT/BitVector.h" 18 | #include "llvm/ADT/Optional.h" 19 | #include "llvm/Support/Error.h" 20 | #include 21 | 22 | // This class represents a glob pattern. Supported metacharacters 23 | // are "*", "?", "\", "[]", "[^]", and "[!]". 24 | namespace llvm { 25 | 26 | template class ArrayRef; 27 | class StringRef; 28 | 29 | class GlobPattern { 30 | public: 31 | static Expected create(StringRef Pat); 32 | bool match(StringRef S) const; 33 | 34 | // Returns true for glob pattern "*". Can be used to avoid expensive 35 | // preparation/acquisition of the input for match(). 36 | bool isTrivialMatchAll() const { 37 | if (Prefix && Prefix->empty()) { 38 | assert(!Suffix); 39 | return true; 40 | } 41 | return false; 42 | } 43 | 44 | private: 45 | bool matchOne(ArrayRef Pat, StringRef S) const; 46 | 47 | // Parsed glob pattern. 48 | std::vector Tokens; 49 | 50 | // The following members are for optimization. 51 | Optional Exact; 52 | Optional Prefix; 53 | Optional Suffix; 54 | }; 55 | } 56 | 57 | #endif // LLVM_SUPPORT_GLOB_PATTERN_H 58 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/InitLLVM.h: -------------------------------------------------------------------------------- 1 | //===- InitLLVM.h -----------------------------------------------*- C++ -*-===// 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 | #ifndef LLVM_SUPPORT_LLVM_H 10 | #define LLVM_SUPPORT_LLVM_H 11 | 12 | #include "llvm/ADT/SmallVector.h" 13 | #include "llvm/Support/Allocator.h" 14 | #include "llvm/Support/PrettyStackTrace.h" 15 | 16 | // The main() functions in typical LLVM tools start with InitLLVM which does 17 | // the following one-time initializations: 18 | // 19 | // 1. Setting up a signal handler so that pretty stack trace is printed out 20 | // if a process crashes. A signal handler that exits when a failed write to 21 | // a pipe occurs may optionally be installed: this is on-by-default. 22 | // 23 | // 2. Set up the global new-handler which is called when a memory allocation 24 | // attempt fails. 25 | // 26 | // 3. If running on Windows, obtain command line arguments using a 27 | // multibyte character-aware API and convert arguments into UTF-8 28 | // encoding, so that you can assume that command line arguments are 29 | // always encoded in UTF-8 on any platform. 30 | // 31 | // InitLLVM calls llvm_shutdown() on destruction, which cleans up 32 | // ManagedStatic objects. 33 | namespace llvm { 34 | class InitLLVM { 35 | public: 36 | InitLLVM(int &Argc, const char **&Argv, 37 | bool InstallPipeSignalExitHandler = true); 38 | InitLLVM(int &Argc, char **&Argv, bool InstallPipeSignalExitHandler = true) 39 | : InitLLVM(Argc, const_cast(Argv), 40 | InstallPipeSignalExitHandler) {} 41 | 42 | ~InitLLVM(); 43 | 44 | private: 45 | BumpPtrAllocator Alloc; 46 | SmallVector Args; 47 | PrettyStackTraceProgram StackPrinter; 48 | }; 49 | } // namespace llvm 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/LICENSE.TXT: -------------------------------------------------------------------------------- 1 | LLVM System Interface Library 2 | ------------------------------------------------------------------------------- 3 | The LLVM System Interface Library is licensed under the Illinois Open Source 4 | License and has the following additional copyright: 5 | 6 | Copyright (C) 2004 eXtensible Systems, Inc. 7 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/Locale.h: -------------------------------------------------------------------------------- 1 | #ifndef LLVM_SUPPORT_LOCALE_H 2 | #define LLVM_SUPPORT_LOCALE_H 3 | 4 | namespace llvm { 5 | class StringRef; 6 | 7 | namespace sys { 8 | namespace locale { 9 | 10 | int columnWidth(StringRef s); 11 | bool isPrint(int c); 12 | 13 | } 14 | } 15 | } 16 | 17 | #endif // LLVM_SUPPORT_LOCALE_H 18 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/MemoryBufferRef.h: -------------------------------------------------------------------------------- 1 | //===- MemoryBufferRef.h - Memory Buffer Reference --------------*- C++ -*-===// 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 | // This file defines the MemoryBuffer interface. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef LLVM_SUPPORT_MEMORYBUFFERREF_H 14 | #define LLVM_SUPPORT_MEMORYBUFFERREF_H 15 | 16 | #include "llvm/ADT/StringRef.h" 17 | 18 | namespace llvm { 19 | 20 | class MemoryBuffer; 21 | 22 | class MemoryBufferRef { 23 | StringRef Buffer; 24 | StringRef Identifier; 25 | 26 | public: 27 | MemoryBufferRef() = default; 28 | MemoryBufferRef(const MemoryBuffer &Buffer); 29 | MemoryBufferRef(StringRef Buffer, StringRef Identifier) 30 | : Buffer(Buffer), Identifier(Identifier) {} 31 | 32 | StringRef getBuffer() const { return Buffer; } 33 | StringRef getBufferIdentifier() const { return Identifier; } 34 | 35 | const char *getBufferStart() const { return Buffer.begin(); } 36 | const char *getBufferEnd() const { return Buffer.end(); } 37 | size_t getBufferSize() const { return Buffer.size(); } 38 | 39 | /// Check pointer identity (not value) of identifier and data. 40 | friend bool operator==(const MemoryBufferRef &LHS, 41 | const MemoryBufferRef &RHS) { 42 | return LHS.Buffer.begin() == RHS.Buffer.begin() && 43 | LHS.Buffer.end() == RHS.Buffer.end() && 44 | LHS.Identifier.begin() == RHS.Identifier.begin() && 45 | LHS.Identifier.end() == RHS.Identifier.end(); 46 | } 47 | 48 | friend bool operator!=(const MemoryBufferRef &LHS, 49 | const MemoryBufferRef &RHS) { 50 | return !(LHS == RHS); 51 | } 52 | }; 53 | 54 | } // namespace llvm 55 | 56 | #endif // LLVM_SUPPORT_MEMORYBUFFERREF_H 57 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/NativeFormatting.h: -------------------------------------------------------------------------------- 1 | //===- NativeFormatting.h - Low level formatting helpers ---------*- C++-*-===// 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 | #ifndef LLVM_SUPPORT_NATIVE_FORMATTING_H 10 | #define LLVM_SUPPORT_NATIVE_FORMATTING_H 11 | 12 | #include "llvm/ADT/Optional.h" 13 | #include 14 | 15 | namespace llvm { 16 | class raw_ostream; 17 | enum class FloatStyle { Exponent, ExponentUpper, Fixed, Percent }; 18 | enum class IntegerStyle { 19 | Integer, 20 | Number, 21 | }; 22 | enum class HexPrintStyle { Upper, Lower, PrefixUpper, PrefixLower }; 23 | 24 | size_t getDefaultPrecision(FloatStyle Style); 25 | 26 | bool isPrefixedHexStyle(HexPrintStyle S); 27 | 28 | void write_integer(raw_ostream &S, unsigned int N, size_t MinDigits, 29 | IntegerStyle Style); 30 | void write_integer(raw_ostream &S, int N, size_t MinDigits, IntegerStyle Style); 31 | void write_integer(raw_ostream &S, unsigned long N, size_t MinDigits, 32 | IntegerStyle Style); 33 | void write_integer(raw_ostream &S, long N, size_t MinDigits, 34 | IntegerStyle Style); 35 | void write_integer(raw_ostream &S, unsigned long long N, size_t MinDigits, 36 | IntegerStyle Style); 37 | void write_integer(raw_ostream &S, long long N, size_t MinDigits, 38 | IntegerStyle Style); 39 | 40 | void write_hex(raw_ostream &S, uint64_t N, HexPrintStyle Style, 41 | Optional Width = None); 42 | void write_double(raw_ostream &S, double D, FloatStyle Style, 43 | Optional Precision = None); 44 | } 45 | 46 | #endif 47 | 48 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/PluginLoader.h: -------------------------------------------------------------------------------- 1 | //===-- llvm/Support/PluginLoader.h - Plugin Loader for Tools ---*- C++ -*-===// 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 | // A tool can #include this file to get a -load option that allows the user to 10 | // load arbitrary shared objects into the tool's address space. Note that this 11 | // header can only be included by a program ONCE, so it should never to used by 12 | // library authors. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef LLVM_SUPPORT_PLUGINLOADER_H 17 | #define LLVM_SUPPORT_PLUGINLOADER_H 18 | 19 | #ifndef DONT_GET_PLUGIN_LOADER_OPTION 20 | #include "llvm/Support/CommandLine.h" 21 | #endif 22 | 23 | #include 24 | 25 | namespace llvm { 26 | struct PluginLoader { 27 | void operator=(const std::string &Filename); 28 | static unsigned getNumPlugins(); 29 | static std::string& getPlugin(unsigned num); 30 | }; 31 | 32 | #ifndef DONT_GET_PLUGIN_LOADER_OPTION 33 | // This causes operator= above to be invoked for every -load option. 34 | static cl::opt > 35 | LoadOpt("load", cl::ZeroOrMore, cl::value_desc("pluginfilename"), 36 | cl::desc("Load the specified plugin")); 37 | #endif 38 | } 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/Printable.h: -------------------------------------------------------------------------------- 1 | //===--- Printable.h - Print function helpers -------------------*- C++ -*-===// 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 | // This file defines the Printable struct. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef LLVM_SUPPORT_PRINTABLE_H 14 | #define LLVM_SUPPORT_PRINTABLE_H 15 | 16 | #include 17 | 18 | namespace llvm { 19 | 20 | class raw_ostream; 21 | 22 | /// Simple wrapper around std::function. 23 | /// This class is useful to construct print helpers for raw_ostream. 24 | /// 25 | /// Example: 26 | /// Printable PrintRegister(unsigned Register) { 27 | /// return Printable([Register](raw_ostream &OS) { 28 | /// OS << getRegisterName(Register); 29 | /// } 30 | /// } 31 | /// ... OS << PrintRegister(Register); ... 32 | /// 33 | /// Implementation note: Ideally this would just be a typedef, but doing so 34 | /// leads to operator << being ambiguous as function has matching constructors 35 | /// in some STL versions. I have seen the problem on gcc 4.6 libstdc++ and 36 | /// microsoft STL. 37 | class Printable { 38 | public: 39 | std::function Print; 40 | Printable(std::function Print) 41 | : Print(std::move(Print)) {} 42 | }; 43 | 44 | inline raw_ostream &operator<<(raw_ostream &OS, const Printable &P) { 45 | P.Print(OS); 46 | return OS; 47 | } 48 | 49 | } 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/RISCVAttributeParser.h: -------------------------------------------------------------------------------- 1 | //===-- RISCVAttributeParser.h - RISCV Attribute Parser ---------*- C++ -*-===// 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 | #ifndef LLVM_SUPPORT_RISCVATTRIBUTEPARSER_H 10 | #define LLVM_SUPPORT_RISCVATTRIBUTEPARSER_H 11 | 12 | #include "llvm/Support/ELFAttributeParser.h" 13 | #include "llvm/Support/RISCVAttributes.h" 14 | 15 | namespace llvm { 16 | class RISCVAttributeParser : public ELFAttributeParser { 17 | struct DisplayHandler { 18 | RISCVAttrs::AttrType attribute; 19 | Error (RISCVAttributeParser::*routine)(unsigned); 20 | }; 21 | static const DisplayHandler displayRoutines[]; 22 | 23 | Error handler(uint64_t tag, bool &handled) override; 24 | 25 | Error unalignedAccess(unsigned tag); 26 | Error stackAlign(unsigned tag); 27 | 28 | public: 29 | RISCVAttributeParser(ScopedPrinter *sw) 30 | : ELFAttributeParser(sw, RISCVAttrs::RISCVAttributeTags, "riscv") {} 31 | RISCVAttributeParser() 32 | : ELFAttributeParser(RISCVAttrs::RISCVAttributeTags, "riscv") {} 33 | }; 34 | 35 | } // namespace llvm 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/RISCVAttributes.h: -------------------------------------------------------------------------------- 1 | //===-- RISCVAttributes.h - RISCV Attributes --------------------*- C++ -*-===// 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 | // This file contains enumerations for RISCV attributes as defined in RISC-V 10 | // ELF psABI specification. 11 | // 12 | // RISC-V ELF psABI specification 13 | // 14 | // https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md 15 | // 16 | //===----------------------------------------------------------------------===// 17 | #ifndef LLVM_SUPPORT_RISCVATTRIBUTES_H 18 | #define LLVM_SUPPORT_RISCVATTRIBUTES_H 19 | 20 | #include "llvm/Support/ELFAttributes.h" 21 | 22 | namespace llvm { 23 | namespace RISCVAttrs { 24 | 25 | extern const TagNameMap RISCVAttributeTags; 26 | 27 | enum AttrType : unsigned { 28 | // Attribute types in ELF/.riscv.attributes. 29 | STACK_ALIGN = 4, 30 | ARCH = 5, 31 | UNALIGNED_ACCESS = 6, 32 | PRIV_SPEC = 8, 33 | PRIV_SPEC_MINOR = 10, 34 | PRIV_SPEC_REVISION = 12, 35 | }; 36 | 37 | enum StackAlign { ALIGN_4 = 4, ALIGN_16 = 16 }; 38 | 39 | enum { NOT_ALLOWED = 0, ALLOWED = 1 }; 40 | 41 | } // namespace RISCVAttrs 42 | } // namespace llvm 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/RISCVTargetParser.def: -------------------------------------------------------------------------------- 1 | #ifndef PROC_ALIAS 2 | #define PROC_ALIAS(NAME, RV32, RV64) 3 | #endif 4 | 5 | PROC_ALIAS("generic", "generic-rv32", "generic-rv64") 6 | PROC_ALIAS("rocket", "rocket-rv32", "rocket-rv64") 7 | PROC_ALIAS("sifive-7-series", "sifive-7-rv32", "sifive-7-rv64") 8 | 9 | #undef PROC_ALIAS 10 | 11 | #ifndef PROC 12 | #define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH) 13 | #endif 14 | 15 | PROC(INVALID, {"invalid"}, FK_INVALID, {""}) 16 | PROC(GENERIC_RV32, {"generic-rv32"}, FK_NONE, {""}) 17 | PROC(GENERIC_RV64, {"generic-rv64"}, FK_64BIT, {""}) 18 | PROC(ROCKET_RV32, {"rocket-rv32"}, FK_NONE, {""}) 19 | PROC(ROCKET_RV64, {"rocket-rv64"}, FK_64BIT, {""}) 20 | PROC(SIFIVE_732, {"sifive-7-rv32"}, FK_NONE, {""}) 21 | PROC(SIFIVE_764, {"sifive-7-rv64"}, FK_64BIT, {""}) 22 | PROC(SIFIVE_E31, {"sifive-e31"}, FK_NONE, {"rv32imac"}) 23 | PROC(SIFIVE_U54, {"sifive-u54"}, FK_64BIT, {"rv64gc"}) 24 | PROC(SIFIVE_E76, {"sifive-e76"}, FK_NONE, {"rv32imafc"}) 25 | PROC(SIFIVE_U74, {"sifive-u74"}, FK_64BIT, {"rv64gc"}) 26 | 27 | #undef PROC 28 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/ReverseIteration.h: -------------------------------------------------------------------------------- 1 | #ifndef LLVM_SUPPORT_REVERSEITERATION_H 2 | #define LLVM_SUPPORT_REVERSEITERATION_H 3 | 4 | #include "llvm/Config/abi-breaking.h" 5 | #include "llvm/Support/PointerLikeTypeTraits.h" 6 | 7 | namespace llvm { 8 | 9 | template 10 | bool shouldReverseIterate() { 11 | #if LLVM_ENABLE_REVERSE_ITERATION 12 | return detail::IsPointerLike::value; 13 | #else 14 | return false; 15 | #endif 16 | } 17 | 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/SMLoc.h: -------------------------------------------------------------------------------- 1 | //===- SMLoc.h - Source location for use with diagnostics -------*- C++ -*-===// 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 | // This file declares the SMLoc class. This class encapsulates a location in 10 | // source code for use in diagnostics. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_SUPPORT_SMLOC_H 15 | #define LLVM_SUPPORT_SMLOC_H 16 | 17 | #include "llvm/ADT/None.h" 18 | #include 19 | 20 | namespace llvm { 21 | 22 | /// Represents a location in source code. 23 | class SMLoc { 24 | const char *Ptr = nullptr; 25 | 26 | public: 27 | SMLoc() = default; 28 | 29 | bool isValid() const { return Ptr != nullptr; } 30 | 31 | bool operator==(const SMLoc &RHS) const { return RHS.Ptr == Ptr; } 32 | bool operator!=(const SMLoc &RHS) const { return RHS.Ptr != Ptr; } 33 | 34 | const char *getPointer() const { return Ptr; } 35 | 36 | static SMLoc getFromPointer(const char *Ptr) { 37 | SMLoc L; 38 | L.Ptr = Ptr; 39 | return L; 40 | } 41 | }; 42 | 43 | /// Represents a range in source code. 44 | /// 45 | /// SMRange is implemented using a half-open range, as is the convention in C++. 46 | /// In the string "abc", the range [1,3) represents the substring "bc", and the 47 | /// range [2,2) represents an empty range between the characters "b" and "c". 48 | class SMRange { 49 | public: 50 | SMLoc Start, End; 51 | 52 | SMRange() = default; 53 | SMRange(NoneType) {} 54 | SMRange(SMLoc St, SMLoc En) : Start(St), End(En) { 55 | assert(Start.isValid() == End.isValid() && 56 | "Start and End should either both be valid or both be invalid!"); 57 | } 58 | 59 | bool isValid() const { return Start.isValid(); } 60 | }; 61 | 62 | } // end namespace llvm 63 | 64 | #endif // LLVM_SUPPORT_SMLOC_H 65 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/SaveAndRestore.h: -------------------------------------------------------------------------------- 1 | //===-- SaveAndRestore.h - Utility -------------------------------*- C++ -*-=// 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 | /// \file 10 | /// This file provides utility classes that use RAII to save and restore 11 | /// values. 12 | /// 13 | //===----------------------------------------------------------------------===// 14 | 15 | #ifndef LLVM_SUPPORT_SAVEANDRESTORE_H 16 | #define LLVM_SUPPORT_SAVEANDRESTORE_H 17 | 18 | namespace llvm { 19 | 20 | /// A utility class that uses RAII to save and restore the value of a variable. 21 | template struct SaveAndRestore { 22 | SaveAndRestore(T &X) : X(X), OldValue(X) {} 23 | SaveAndRestore(T &X, const T &NewValue) : X(X), OldValue(X) { 24 | X = NewValue; 25 | } 26 | ~SaveAndRestore() { X = OldValue; } 27 | T get() { return OldValue; } 28 | 29 | private: 30 | T &X; 31 | T OldValue; 32 | }; 33 | 34 | } // namespace llvm 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/Signposts.h: -------------------------------------------------------------------------------- 1 | //===-- llvm/Support/Signposts.h - Interval debug annotations ---*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | /// \file Some OS's provide profilers that allow applications to provide custom 11 | /// annotations to the profiler. For example, on Xcode 10 and later 'signposts' 12 | /// can be emitted by the application and these will be rendered to the Points 13 | /// of Interest track on the instruments timeline. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | 17 | #ifndef LLVM_SUPPORT_SIGNPOSTS_H 18 | #define LLVM_SUPPORT_SIGNPOSTS_H 19 | 20 | #include "llvm/ADT/StringRef.h" 21 | 22 | namespace llvm { 23 | class SignpostEmitterImpl; 24 | 25 | /// Manages the emission of signposts into the recording method supported by 26 | /// the OS. 27 | class SignpostEmitter { 28 | SignpostEmitterImpl *Impl; 29 | 30 | public: 31 | SignpostEmitter(); 32 | ~SignpostEmitter(); 33 | 34 | bool isEnabled() const; 35 | 36 | /// Begin a signposted interval for a given object. 37 | void startInterval(const void *O, StringRef Name); 38 | /// End a signposted interval for a given object. 39 | void endInterval(const void *O, StringRef Name); 40 | }; 41 | 42 | } // end namespace llvm 43 | 44 | #endif // ifndef LLVM_SUPPORT_SIGNPOSTS_H 45 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/Solaris/sys/regset.h: -------------------------------------------------------------------------------- 1 | /*===- llvm/Support/Solaris/sys/regset.h ------------------------*- C++ -*-===* 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 | * This file works around excessive name space pollution from the system header 10 | * on Solaris hosts. 11 | * 12 | *===----------------------------------------------------------------------===*/ 13 | 14 | #ifndef LLVM_SUPPORT_SOLARIS_SYS_REGSET_H 15 | 16 | #include_next 17 | 18 | #undef CS 19 | #undef DS 20 | #undef ES 21 | #undef FS 22 | #undef GS 23 | #undef SS 24 | #undef EAX 25 | #undef ECX 26 | #undef EDX 27 | #undef EBX 28 | #undef ESP 29 | #undef EBP 30 | #undef ESI 31 | #undef EDI 32 | #undef EIP 33 | #undef UESP 34 | #undef EFL 35 | #undef ERR 36 | #undef TRAPNO 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/SystemUtils.h: -------------------------------------------------------------------------------- 1 | //===- SystemUtils.h - Utilities to do low-level system stuff ---*- C++ -*-===// 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 | // This file contains functions used to do a variety of low-level, often 10 | // system-specific, tasks. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_SUPPORT_SYSTEMUTILS_H 15 | #define LLVM_SUPPORT_SYSTEMUTILS_H 16 | 17 | namespace llvm { 18 | class raw_ostream; 19 | 20 | /// Determine if the raw_ostream provided is connected to a terminal. If so, 21 | /// generate a warning message to errs() advising against display of bitcode 22 | /// and return true. Otherwise just return false. 23 | /// Check for output written to a console 24 | bool CheckBitcodeOutputToConsole( 25 | raw_ostream &stream_to_check ///< The stream to be checked 26 | ); 27 | 28 | } // namespace llvm 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/TarWriter.h: -------------------------------------------------------------------------------- 1 | //===-- llvm/Support/TarWriter.h - Tar archive file creator -----*- C++ -*-===// 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 | #ifndef LLVM_SUPPORT_TAR_WRITER_H 10 | #define LLVM_SUPPORT_TAR_WRITER_H 11 | 12 | #include "llvm/ADT/StringRef.h" 13 | #include "llvm/ADT/StringSet.h" 14 | #include "llvm/Support/Error.h" 15 | #include "llvm/Support/raw_ostream.h" 16 | 17 | namespace llvm { 18 | class TarWriter { 19 | public: 20 | static Expected> create(StringRef OutputPath, 21 | StringRef BaseDir); 22 | 23 | void append(StringRef Path, StringRef Data); 24 | 25 | private: 26 | TarWriter(int FD, StringRef BaseDir); 27 | raw_fd_ostream OS; 28 | std::string BaseDir; 29 | StringSet<> Files; 30 | }; 31 | } 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/Valgrind.h: -------------------------------------------------------------------------------- 1 | //===- llvm/Support/Valgrind.h - Communication with Valgrind ----*- C++ -*-===// 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 | // Methods for communicating with a valgrind instance this program is running 10 | // under. These are all no-ops unless LLVM was configured on a system with the 11 | // valgrind headers installed and valgrind is controlling this process. 12 | // 13 | //===----------------------------------------------------------------------===// 14 | 15 | #ifndef LLVM_SUPPORT_VALGRIND_H 16 | #define LLVM_SUPPORT_VALGRIND_H 17 | 18 | #include 19 | 20 | namespace llvm { 21 | namespace sys { 22 | // True if Valgrind is controlling this process. 23 | bool RunningOnValgrind(); 24 | 25 | // Discard valgrind's translation of code in the range [Addr .. Addr + Len). 26 | // Otherwise valgrind may continue to execute the old version of the code. 27 | void ValgrindDiscardTranslations(const void *Addr, size_t Len); 28 | } // namespace sys 29 | } // end namespace llvm 30 | 31 | #endif // LLVM_SUPPORT_VALGRIND_H 32 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/Watchdog.h: -------------------------------------------------------------------------------- 1 | //===--- Watchdog.h - Watchdog timer ----------------------------*- C++ -*-===// 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 | // This file declares the llvm::sys::Watchdog class. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef LLVM_SUPPORT_WATCHDOG_H 14 | #define LLVM_SUPPORT_WATCHDOG_H 15 | 16 | #include "llvm/Support/Compiler.h" 17 | 18 | namespace llvm { 19 | namespace sys { 20 | 21 | /// This class provides an abstraction for a timeout around an operation 22 | /// that must complete in a given amount of time. Failure to complete before 23 | /// the timeout is an unrecoverable situation and no mechanisms to attempt 24 | /// to handle it are provided. 25 | class Watchdog { 26 | public: 27 | Watchdog(unsigned int seconds); 28 | ~Watchdog(); 29 | private: 30 | // Noncopyable. 31 | Watchdog(const Watchdog &other) = delete; 32 | Watchdog &operator=(const Watchdog &other) = delete; 33 | }; 34 | } 35 | } 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/WindowsError.h: -------------------------------------------------------------------------------- 1 | //===-- WindowsError.h - Support for mapping windows errors to posix-------===// 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 | #ifndef LLVM_SUPPORT_WINDOWSERROR_H 10 | #define LLVM_SUPPORT_WINDOWSERROR_H 11 | 12 | #include 13 | 14 | namespace llvm { 15 | std::error_code mapWindowsError(unsigned EV); 16 | } 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/raw_os_ostream.h: -------------------------------------------------------------------------------- 1 | //===- raw_os_ostream.h - std::ostream adaptor for raw_ostream --*- C++ -*-===// 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 | // This file defines the raw_os_ostream class. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef LLVM_SUPPORT_RAW_OS_OSTREAM_H 14 | #define LLVM_SUPPORT_RAW_OS_OSTREAM_H 15 | 16 | #include "llvm/Support/raw_ostream.h" 17 | #include 18 | 19 | namespace llvm { 20 | 21 | /// raw_os_ostream - A raw_ostream that writes to an std::ostream. This is a 22 | /// simple adaptor class. It does not check for output errors; clients should 23 | /// use the underlying stream to detect errors. 24 | class raw_os_ostream : public raw_ostream { 25 | std::ostream &OS; 26 | 27 | /// write_impl - See raw_ostream::write_impl. 28 | void write_impl(const char *Ptr, size_t Size) override; 29 | 30 | /// current_pos - Return the current position within the stream, not 31 | /// counting the bytes currently in the buffer. 32 | uint64_t current_pos() const override; 33 | 34 | public: 35 | raw_os_ostream(std::ostream &O) : OS(O) {} 36 | ~raw_os_ostream() override; 37 | }; 38 | 39 | } // end llvm namespace 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/raw_sha1_ostream.h: -------------------------------------------------------------------------------- 1 | //==- raw_sha1_ostream.h - raw_ostream that compute SHA1 --*- C++ -*-==// 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 | // This file defines the raw_sha1_ostream class. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef LLVM_SUPPORT_RAW_SHA1_OSTREAM_H 14 | #define LLVM_SUPPORT_RAW_SHA1_OSTREAM_H 15 | 16 | #include "llvm/ADT/ArrayRef.h" 17 | #include "llvm/Support/SHA1.h" 18 | #include "llvm/Support/raw_ostream.h" 19 | 20 | namespace llvm { 21 | 22 | /// A raw_ostream that hash the content using the sha1 algorithm. 23 | class raw_sha1_ostream : public raw_ostream { 24 | SHA1 State; 25 | 26 | /// See raw_ostream::write_impl. 27 | void write_impl(const char *Ptr, size_t Size) override { 28 | State.update(ArrayRef((const uint8_t *)Ptr, Size)); 29 | } 30 | 31 | public: 32 | /// Return the current SHA1 hash for the content of the stream 33 | StringRef sha1() { 34 | flush(); 35 | return State.result(); 36 | } 37 | 38 | /// Reset the internal state to start over from scratch. 39 | void resetHash() { State.init(); } 40 | 41 | uint64_t current_pos() const override { return 0; } 42 | }; 43 | 44 | } // end llvm namespace 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/Support/thread.h: -------------------------------------------------------------------------------- 1 | //===-- llvm/Support/thread.h - Wrapper for ------------*- C++ -*-===// 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 | // This header is a wrapper for that works around problems with the 10 | // MSVC headers when exceptions are disabled. It also provides llvm::thread, 11 | // which is either a typedef of std::thread or a replacement that calls the 12 | // function synchronously depending on the value of LLVM_ENABLE_THREADS. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef LLVM_SUPPORT_THREAD_H 17 | #define LLVM_SUPPORT_THREAD_H 18 | 19 | #include "llvm/Config/llvm-config.h" 20 | 21 | #if LLVM_ENABLE_THREADS 22 | 23 | #include 24 | 25 | namespace llvm { 26 | typedef std::thread thread; 27 | } 28 | 29 | #else // !LLVM_ENABLE_THREADS 30 | 31 | #include 32 | 33 | namespace llvm { 34 | 35 | struct thread { 36 | thread() {} 37 | thread(thread &&other) {} 38 | template 39 | explicit thread(Function &&f, Args &&... args) { 40 | f(std::forward(args)...); 41 | } 42 | thread(const thread &) = delete; 43 | 44 | void join() {} 45 | static unsigned hardware_concurrency() { return 1; }; 46 | }; 47 | 48 | } 49 | 50 | #endif // LLVM_ENABLE_THREADS 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/IR/Assumptions.cpp: -------------------------------------------------------------------------------- 1 | //===- Assumptions.cpp ------ Collection of helpers for assumptions -------===// 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 | //===----------------------------------------------------------------------===// 10 | 11 | #include "llvm/IR/Assumptions.h" 12 | #include "llvm/IR/Attributes.h" 13 | #include "llvm/IR/Function.h" 14 | 15 | using namespace llvm; 16 | 17 | bool llvm::hasAssumption(Function &F, 18 | const KnownAssumptionString &AssumptionStr) { 19 | const Attribute &A = F.getFnAttribute(AssumptionAttrKey); 20 | if (!A.isValid()) 21 | return false; 22 | assert(A.isStringAttribute() && "Expected a string attribute!"); 23 | 24 | SmallVector Strings; 25 | A.getValueAsString().split(Strings, ","); 26 | 27 | return llvm::any_of(Strings, [=](StringRef Assumption) { 28 | return Assumption == AssumptionStr; 29 | }); 30 | } 31 | 32 | StringSet<> llvm::KnownAssumptionStrings({ 33 | "omp_no_openmp", // OpenMP 5.1 34 | "omp_no_openmp_routines", // OpenMP 5.1 35 | "omp_no_parallelism", // OpenMP 5.1 36 | }); 37 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/IR/GVMaterializer.cpp: -------------------------------------------------------------------------------- 1 | //===-- GVMaterializer.cpp - Base implementation for GV materializers -----===// 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 | // Minimal implementation of the abstract interface for materializing 10 | // GlobalValues. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #include "llvm/IR/GVMaterializer.h" 15 | using namespace llvm; 16 | 17 | GVMaterializer::~GVMaterializer() {} 18 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/IR/MetadataImpl.h: -------------------------------------------------------------------------------- 1 | //===- MetadataImpl.h - Helpers for implementing metadata -----------------===// 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 | // This file has private helpers for implementing metadata types. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef LLVM_IR_METADATAIMPL_H 14 | #define LLVM_IR_METADATAIMPL_H 15 | 16 | #include "llvm/ADT/DenseSet.h" 17 | #include "llvm/IR/Metadata.h" 18 | 19 | namespace llvm { 20 | 21 | template 22 | static T *getUniqued(DenseSet &Store, 23 | const typename InfoT::KeyTy &Key) { 24 | auto I = Store.find_as(Key); 25 | return I == Store.end() ? nullptr : *I; 26 | } 27 | 28 | template T *MDNode::storeImpl(T *N, StorageType Storage) { 29 | switch (Storage) { 30 | case Uniqued: 31 | llvm_unreachable("Cannot unique without a uniquing-store"); 32 | case Distinct: 33 | N->storeDistinctInContext(); 34 | break; 35 | case Temporary: 36 | break; 37 | } 38 | return N; 39 | } 40 | 41 | template 42 | T *MDNode::storeImpl(T *N, StorageType Storage, StoreT &Store) { 43 | switch (Storage) { 44 | case Uniqued: 45 | Store.insert(N); 46 | break; 47 | case Distinct: 48 | N->storeDistinctInContext(); 49 | break; 50 | case Temporary: 51 | break; 52 | } 53 | return N; 54 | } 55 | 56 | } // end namespace llvm 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/IR/PassInstrumentation.cpp: -------------------------------------------------------------------------------- 1 | //===- PassInstrumentation.cpp - Pass Instrumentation interface -*- C++ -*-===// 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 | /// \file 9 | /// 10 | /// This file provides the implementation of PassInstrumentation class. 11 | /// 12 | //===----------------------------------------------------------------------===// 13 | 14 | #include "llvm/IR/PassInstrumentation.h" 15 | #include "llvm/ADT/STLExtras.h" 16 | #include "llvm/IR/PassManager.h" 17 | 18 | namespace llvm { 19 | 20 | void PassInstrumentationCallbacks::addClassToPassName(StringRef ClassName, 21 | StringRef PassName) { 22 | ClassToPassName[ClassName] = PassName.str(); 23 | } 24 | 25 | StringRef 26 | PassInstrumentationCallbacks::getPassNameForClassName(StringRef ClassName) { 27 | return ClassToPassName[ClassName]; 28 | } 29 | 30 | AnalysisKey PassInstrumentationAnalysis::Key; 31 | 32 | bool isSpecialPass(StringRef PassID, const std::vector &Specials) { 33 | size_t Pos = PassID.find('<'); 34 | StringRef Prefix = PassID; 35 | if (Pos != StringRef::npos) 36 | Prefix = PassID.substr(0, Pos); 37 | return any_of(Specials, [Prefix](StringRef S) { return Prefix.endswith(S); }); 38 | } 39 | 40 | } // namespace llvm 41 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/IR/Statepoint.cpp: -------------------------------------------------------------------------------- 1 | //===-- IR/Statepoint.cpp -- gc.statepoint utilities --- -----------------===// 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 | // This file contains some utility functions to help recognize gc.statepoint 10 | // intrinsics. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #include "llvm/IR/Statepoint.h" 15 | 16 | #include "llvm/IR/Function.h" 17 | 18 | using namespace llvm; 19 | 20 | bool llvm::isStatepointDirectiveAttr(Attribute Attr) { 21 | return Attr.hasAttribute("statepoint-id") || 22 | Attr.hasAttribute("statepoint-num-patch-bytes"); 23 | } 24 | 25 | StatepointDirectives 26 | llvm::parseStatepointDirectivesFromAttrs(AttributeList AS) { 27 | StatepointDirectives Result; 28 | 29 | Attribute AttrID = 30 | AS.getAttribute(AttributeList::FunctionIndex, "statepoint-id"); 31 | uint64_t StatepointID; 32 | if (AttrID.isStringAttribute()) 33 | if (!AttrID.getValueAsString().getAsInteger(10, StatepointID)) 34 | Result.StatepointID = StatepointID; 35 | 36 | uint32_t NumPatchBytes; 37 | Attribute AttrNumPatchBytes = AS.getAttribute(AttributeList::FunctionIndex, 38 | "statepoint-num-patch-bytes"); 39 | if (AttrNumPatchBytes.isStringAttribute()) 40 | if (!AttrNumPatchBytes.getValueAsString().getAsInteger(10, NumPatchBytes)) 41 | Result.NumPatchBytes = NumPatchBytes; 42 | 43 | return Result; 44 | } 45 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/IR/Use.cpp: -------------------------------------------------------------------------------- 1 | //===-- Use.cpp - Implement the Use class ---------------------------------===// 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/IR/Use.h" 10 | #include "llvm/IR/User.h" 11 | #include "llvm/IR/Value.h" 12 | #include 13 | 14 | namespace llvm { 15 | 16 | void Use::swap(Use &RHS) { 17 | if (Val == RHS.Val) 18 | return; 19 | 20 | std::swap(Val, RHS.Val); 21 | std::swap(Next, RHS.Next); 22 | std::swap(Prev, RHS.Prev); 23 | 24 | *Prev = this; 25 | if (Next) 26 | Next->Prev = &Next; 27 | 28 | *RHS.Prev = &RHS; 29 | if (RHS.Next) 30 | RHS.Next->Prev = &RHS.Next; 31 | } 32 | 33 | unsigned Use::getOperandNo() const { 34 | return this - getUser()->op_begin(); 35 | } 36 | 37 | void Use::zap(Use *Start, const Use *Stop, bool del) { 38 | while (Start != Stop) 39 | (--Stop)->~Use(); 40 | if (del) 41 | ::operator delete(Start); 42 | } 43 | 44 | } // namespace llvm 45 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/ABIBreak.cpp: -------------------------------------------------------------------------------- 1 | //===----- lib/Support/ABIBreak.cpp - EnableABIBreakingChecks -------------===// 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/Config/abi-breaking.h" 10 | 11 | #ifndef _MSC_VER 12 | namespace llvm { 13 | 14 | // One of these two variables will be referenced by a symbol defined in 15 | // llvm-config.h. We provide a link-time (or load time for DSO) failure when 16 | // there is a mismatch in the build configuration of the API client and LLVM. 17 | #if LLVM_ENABLE_ABI_BREAKING_CHECKS 18 | int EnableABIBreakingChecks; 19 | #else 20 | int DisableABIBreakingChecks; 21 | #endif 22 | 23 | } // end namespace llvm 24 | #endif 25 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/APSInt.cpp: -------------------------------------------------------------------------------- 1 | //===-- llvm/ADT/APSInt.cpp - Arbitrary Precision Signed Int ---*- C++ -*--===// 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 | // This file implements the APSInt class, which is a simple class that 10 | // represents an arbitrary sized integer that knows its signedness. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #include "llvm/ADT/APSInt.h" 15 | #include "llvm/ADT/FoldingSet.h" 16 | #include "llvm/ADT/StringRef.h" 17 | #include 18 | 19 | using namespace llvm; 20 | 21 | APSInt::APSInt(StringRef Str) { 22 | assert(!Str.empty() && "Invalid string length"); 23 | 24 | // (Over-)estimate the required number of bits. 25 | unsigned NumBits = ((Str.size() * 64) / 19) + 2; 26 | APInt Tmp(NumBits, Str, /*radix=*/10); 27 | if (Str[0] == '-') { 28 | unsigned MinBits = Tmp.getMinSignedBits(); 29 | if (MinBits < NumBits) 30 | Tmp = Tmp.trunc(std::max(1, MinBits)); 31 | *this = APSInt(Tmp, /*isUnsigned=*/false); 32 | return; 33 | } 34 | unsigned ActiveBits = Tmp.getActiveBits(); 35 | if (ActiveBits < NumBits) 36 | Tmp = Tmp.trunc(std::max(1, ActiveBits)); 37 | *this = APSInt(Tmp, /*isUnsigned=*/true); 38 | } 39 | 40 | void APSInt::Profile(FoldingSetNodeID& ID) const { 41 | ID.AddInteger((unsigned) (IsUnsigned ? 1 : 0)); 42 | APInt::Profile(ID); 43 | } 44 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/ARMWinEH.cpp: -------------------------------------------------------------------------------- 1 | //===-- ARMWinEH.cpp - Windows on ARM EH Support Functions ------*- C++ -*-===// 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/Support/ARMWinEH.h" 10 | #include "llvm/Support/raw_ostream.h" 11 | 12 | namespace llvm { 13 | namespace ARM { 14 | namespace WinEH { 15 | std::pair SavedRegisterMask(const RuntimeFunction &RF) { 16 | uint8_t NumRegisters = RF.Reg(); 17 | uint8_t RegistersVFP = RF.R(); 18 | uint8_t LinkRegister = RF.L(); 19 | uint8_t ChainedFrame = RF.C(); 20 | 21 | uint16_t GPRMask = (ChainedFrame << 11) | (LinkRegister << 14); 22 | uint32_t VFPMask = 0; 23 | 24 | if (RegistersVFP) 25 | VFPMask |= (((1 << ((NumRegisters + 1) % 8)) - 1) << 8); 26 | else 27 | GPRMask |= (((1 << (NumRegisters + 1)) - 1) << 4); 28 | 29 | if (PrologueFolding(RF)) 30 | GPRMask |= (((1 << (NumRegisters + 1)) - 1) << (~RF.StackAdjust() & 0x3)); 31 | 32 | return std::make_pair(GPRMask, VFPMask); 33 | } 34 | } 35 | } 36 | } 37 | 38 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/Allocator.cpp: -------------------------------------------------------------------------------- 1 | //===--- Allocator.cpp - Simple memory allocation abstraction -------------===// 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 | // This file implements the BumpPtrAllocator interface. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #include "llvm/Support/Allocator.h" 14 | #include "llvm/Support/raw_ostream.h" 15 | 16 | namespace llvm { 17 | 18 | namespace detail { 19 | 20 | void printBumpPtrAllocatorStats(unsigned NumSlabs, size_t BytesAllocated, 21 | size_t TotalMemory) { 22 | errs() << "\nNumber of memory regions: " << NumSlabs << '\n' 23 | << "Bytes used: " << BytesAllocated << '\n' 24 | << "Bytes allocated: " << TotalMemory << '\n' 25 | << "Bytes wasted: " << (TotalMemory - BytesAllocated) 26 | << " (includes alignment, etc)\n"; 27 | } 28 | 29 | } // End namespace detail. 30 | 31 | void PrintRecyclerStats(size_t Size, 32 | size_t Align, 33 | size_t FreeListSize) { 34 | errs() << "Recycler element size: " << Size << '\n' 35 | << "Recycler element alignment: " << Align << '\n' 36 | << "Number of elements free for recycling: " << FreeListSize << '\n'; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/Atomic.cpp: -------------------------------------------------------------------------------- 1 | //===-- Atomic.cpp - Atomic Operations --------------------------*- C++ -*-===// 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 | // This file implements atomic operations. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #include "llvm/Support/Atomic.h" 14 | #include "llvm/Config/llvm-config.h" 15 | 16 | using namespace llvm; 17 | 18 | #if defined(_MSC_VER) 19 | #include 20 | 21 | // We must include windows.h after intrin.h. 22 | #include 23 | #undef MemoryFence 24 | #endif 25 | 26 | #if defined(__GNUC__) || (defined(__IBMCPP__) && __IBMCPP__ >= 1210) 27 | #define GNU_ATOMICS 28 | #endif 29 | 30 | void sys::MemoryFence() { 31 | #if LLVM_HAS_ATOMICS == 0 32 | return; 33 | #else 34 | # if defined(GNU_ATOMICS) 35 | __sync_synchronize(); 36 | # elif defined(_MSC_VER) 37 | MemoryBarrier(); 38 | # else 39 | # error No memory fence implementation for your platform! 40 | # endif 41 | #endif 42 | } 43 | 44 | sys::cas_flag sys::CompareAndSwap(volatile sys::cas_flag* ptr, 45 | sys::cas_flag new_value, 46 | sys::cas_flag old_value) { 47 | #if LLVM_HAS_ATOMICS == 0 48 | sys::cas_flag result = *ptr; 49 | if (result == old_value) 50 | *ptr = new_value; 51 | return result; 52 | #elif defined(GNU_ATOMICS) 53 | return __sync_val_compare_and_swap(ptr, old_value, new_value); 54 | #elif defined(_MSC_VER) 55 | return InterlockedCompareExchange(ptr, new_value, old_value); 56 | #else 57 | # error No compare-and-swap implementation for your platform! 58 | #endif 59 | } 60 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/BinaryStreamError.cpp: -------------------------------------------------------------------------------- 1 | //===- BinaryStreamError.cpp - Error extensions for streams -----*- C++ -*-===// 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/Support/BinaryStreamError.h" 10 | #include "llvm/Support/ErrorHandling.h" 11 | 12 | using namespace llvm; 13 | 14 | char BinaryStreamError::ID = 0; 15 | 16 | BinaryStreamError::BinaryStreamError(stream_error_code C) 17 | : BinaryStreamError(C, "") {} 18 | 19 | BinaryStreamError::BinaryStreamError(StringRef Context) 20 | : BinaryStreamError(stream_error_code::unspecified, Context) {} 21 | 22 | BinaryStreamError::BinaryStreamError(stream_error_code C, StringRef Context) 23 | : Code(C) { 24 | ErrMsg = "Stream Error: "; 25 | switch (C) { 26 | case stream_error_code::unspecified: 27 | ErrMsg += "An unspecified error has occurred."; 28 | break; 29 | case stream_error_code::stream_too_short: 30 | ErrMsg += "The stream is too short to perform the requested operation."; 31 | break; 32 | case stream_error_code::invalid_array_size: 33 | ErrMsg += "The buffer size is not a multiple of the array element size."; 34 | break; 35 | case stream_error_code::invalid_offset: 36 | ErrMsg += "The specified offset is invalid for the current stream."; 37 | break; 38 | case stream_error_code::filesystem_error: 39 | ErrMsg += "An I/O error occurred on the file system."; 40 | break; 41 | } 42 | 43 | if (!Context.empty()) { 44 | ErrMsg += " "; 45 | ErrMsg += Context; 46 | } 47 | } 48 | 49 | void BinaryStreamError::log(raw_ostream &OS) const { OS << ErrMsg; } 50 | 51 | StringRef BinaryStreamError::getErrorMessage() const { return ErrMsg; } 52 | 53 | std::error_code BinaryStreamError::convertToErrorCode() const { 54 | return inconvertibleErrorCode(); 55 | } 56 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/BuryPointer.cpp: -------------------------------------------------------------------------------- 1 | //===- BuryPointer.cpp - Memory Manipulation/Leak ---------------*- C++ -*-===// 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/Support/BuryPointer.h" 10 | #include "llvm/Support/Compiler.h" 11 | #include 12 | 13 | namespace llvm { 14 | 15 | void BuryPointer(const void *Ptr) { 16 | // This function may be called only a small fixed amount of times per each 17 | // invocation, otherwise we do actually have a leak which we want to report. 18 | // If this function is called more than kGraveYardMaxSize times, the pointers 19 | // will not be properly buried and a leak detector will report a leak, which 20 | // is what we want in such case. 21 | static const size_t kGraveYardMaxSize = 16; 22 | LLVM_ATTRIBUTE_UNUSED static const void *GraveYard[kGraveYardMaxSize]; 23 | static std::atomic GraveYardSize; 24 | unsigned Idx = GraveYardSize++; 25 | if (Idx >= kGraveYardMaxSize) 26 | return; 27 | GraveYard[Idx] = Ptr; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/COM.cpp: -------------------------------------------------------------------------------- 1 | //===-- COM.cpp - Implement COM utility classes -----------------*- C++ -*-===// 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 | // This file implements utility classes related to COM. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #include "llvm/Support/COM.h" 14 | 15 | #include "llvm/Config/llvm-config.h" 16 | 17 | // Include the platform-specific parts of this class. 18 | //#ifdef LLVM_ON_UNIX 19 | //#include "Unix/COM.inc" 20 | //#elif defined(_WIN32) 21 | //#include "Windows/COM.inc" 22 | //#endif 23 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/ELFAttributes.cpp: -------------------------------------------------------------------------------- 1 | //===-- ELFAttributes.cpp - ELF Attributes --------------------------------===// 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/Support/ELFAttributes.h" 10 | #include "llvm/ADT/StringRef.h" 11 | 12 | using namespace llvm; 13 | 14 | StringRef ELFAttrs::attrTypeAsString(unsigned attr, TagNameMap tagNameMap, 15 | bool hasTagPrefix) { 16 | auto tagNameIt = find_if( 17 | tagNameMap, [attr](const TagNameItem item) { return item.attr == attr; }); 18 | if (tagNameIt == tagNameMap.end()) 19 | return ""; 20 | StringRef tagName = tagNameIt->tagName; 21 | return hasTagPrefix ? tagName : tagName.drop_front(4); 22 | } 23 | 24 | Optional ELFAttrs::attrTypeFromString(StringRef tag, 25 | TagNameMap tagNameMap) { 26 | bool hasTagPrefix = tag.startswith("Tag_"); 27 | auto tagNameIt = 28 | find_if(tagNameMap, [tag, hasTagPrefix](const TagNameItem item) { 29 | return item.tagName.drop_front(hasTagPrefix ? 0 : 4) == tag; 30 | }); 31 | if (tagNameIt == tagNameMap.end()) 32 | return None; 33 | return tagNameIt->attr; 34 | } 35 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/ExtensibleRTTI.cpp: -------------------------------------------------------------------------------- 1 | //===----- lib/Support/ExtensibleRTTI.cpp - ExtensibleRTTI utilities ------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | #include "llvm/Support/ExtensibleRTTI.h" 11 | 12 | void llvm::RTTIRoot::anchor() {} 13 | char llvm::RTTIRoot::ID = 0; 14 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/Hashing.cpp: -------------------------------------------------------------------------------- 1 | //===-------------- lib/Support/Hashing.cpp -------------------------------===// 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 | // This file provides implementation bits for the LLVM common hashing 10 | // infrastructure. Documentation and most of the other information is in the 11 | // header file. 12 | // 13 | //===----------------------------------------------------------------------===// 14 | 15 | #include "llvm/ADT/Hashing.h" 16 | 17 | using namespace llvm; 18 | 19 | // Provide a definition and static initializer for the fixed seed. This 20 | // initializer should always be zero to ensure its value can never appear to be 21 | // non-zero, even during dynamic initialization. 22 | uint64_t llvm::hashing::detail::fixed_seed_override = 0; 23 | 24 | // Implement the function for forced setting of the fixed seed. 25 | // FIXME: Use atomic operations here so that there is no data race. 26 | void llvm::set_fixed_execution_hash_seed(uint64_t fixed_value) { 27 | hashing::detail::fixed_seed_override = fixed_value; 28 | } 29 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/InstructionCost.cpp: -------------------------------------------------------------------------------- 1 | //===- InstructionCost.cpp --------------------------------------*- C++ -*-===// 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 | /// \file 9 | /// This file includes the function definitions for the InstructionCost class 10 | /// that is used when calculating the cost of an instruction, or a group of 11 | /// instructions. 12 | //===----------------------------------------------------------------------===// 13 | 14 | #include "llvm/Support/InstructionCost.h" 15 | #include "llvm/Support/raw_ostream.h" 16 | 17 | using namespace llvm; 18 | 19 | void InstructionCost::print(raw_ostream &OS) const { 20 | if (isValid()) 21 | OS << Value; 22 | else 23 | OS << "Invalid"; 24 | } 25 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/LEB128.cpp: -------------------------------------------------------------------------------- 1 | //===- LEB128.cpp - LEB128 utility functions implementation -----*- C++ -*-===// 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 | // This file implements some utility functions for encoding SLEB128 and 10 | // ULEB128 values. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #include "llvm/Support/LEB128.h" 15 | 16 | namespace llvm { 17 | 18 | /// Utility function to get the size of the ULEB128-encoded value. 19 | unsigned getULEB128Size(uint64_t Value) { 20 | unsigned Size = 0; 21 | do { 22 | Value >>= 7; 23 | Size += sizeof(int8_t); 24 | } while (Value); 25 | return Size; 26 | } 27 | 28 | /// Utility function to get the size of the SLEB128-encoded value. 29 | unsigned getSLEB128Size(int64_t Value) { 30 | unsigned Size = 0; 31 | int Sign = Value >> (8 * sizeof(Value) - 1); 32 | bool IsMore; 33 | 34 | do { 35 | unsigned Byte = Value & 0x7f; 36 | Value >>= 7; 37 | IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0; 38 | Size += sizeof(int8_t); 39 | } while (IsMore); 40 | return Size; 41 | } 42 | 43 | } // namespace llvm 44 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/Locale.cpp: -------------------------------------------------------------------------------- 1 | #include "llvm/Support/Locale.h" 2 | #include "llvm/ADT/StringRef.h" 3 | #include "llvm/Support/Unicode.h" 4 | 5 | namespace llvm { 6 | namespace sys { 7 | namespace locale { 8 | 9 | int columnWidth(StringRef Text) { 10 | return llvm::sys::unicode::columnWidthUTF8(Text); 11 | } 12 | 13 | bool isPrint(int UCS) { 14 | return llvm::sys::unicode::isPrintable(UCS); 15 | } 16 | 17 | } // namespace locale 18 | } // namespace sys 19 | } // namespace llvm 20 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/MathExtras.cpp: -------------------------------------------------------------------------------- 1 | //===-- MathExtras.cpp - Implement the MathExtras header --------------===// 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 | // This file implements the MathExtras.h header 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #include "llvm/Support/MathExtras.h" 14 | 15 | #ifdef _MSC_VER 16 | #include 17 | #else 18 | #include 19 | #endif 20 | 21 | namespace llvm { 22 | 23 | #if defined(_MSC_VER) 24 | // Visual Studio defines the HUGE_VAL class of macros using purposeful 25 | // constant arithmetic overflow, which it then warns on when encountered. 26 | const float huge_valf = std::numeric_limits::infinity(); 27 | #else 28 | const float huge_valf = HUGE_VALF; 29 | #endif 30 | 31 | } 32 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/MemAlloc.cpp: -------------------------------------------------------------------------------- 1 | //===- MemAlloc.cpp - Memory allocation functions -------------------------===// 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/Support/MemAlloc.h" 10 | 11 | // These are out of line to have __cpp_aligned_new not affect ABI. 12 | 13 | LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * 14 | llvm::allocate_buffer(size_t Size, size_t Alignment) { 15 | return ::operator new(Size 16 | #ifdef __cpp_aligned_new 17 | , 18 | std::align_val_t(Alignment) 19 | #endif 20 | ); 21 | } 22 | 23 | void llvm::deallocate_buffer(void *Ptr, size_t Size, size_t Alignment) { 24 | ::operator delete(Ptr 25 | #ifdef __cpp_sized_deallocation 26 | , 27 | Size 28 | #endif 29 | #ifdef __cpp_aligned_new 30 | , 31 | std::align_val_t(Alignment) 32 | #endif 33 | ); 34 | } 35 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/Memory.cpp: -------------------------------------------------------------------------------- 1 | //===- Memory.cpp - Memory Handling Support ---------------------*- C++ -*-===// 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 | // This file defines some helpful functions for allocating memory and dealing 10 | // with memory mapped files 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #include "llvm/Support/Memory.h" 15 | #include "llvm/Config/llvm-config.h" 16 | #include "llvm/Support/Valgrind.h" 17 | 18 | #ifndef NDEBUG 19 | #include "llvm/Support/raw_ostream.h" 20 | #endif // ifndef NDEBUG 21 | 22 | // Include the platform-specific parts of this class. 23 | #ifdef LLVM_ON_UNIX 24 | #include "Unix/Memory.inc" 25 | #endif 26 | #ifdef _WIN32 27 | #include "Windows/Memory.inc" 28 | #endif 29 | 30 | #ifndef NDEBUG 31 | 32 | namespace llvm { 33 | namespace sys { 34 | 35 | raw_ostream &operator<<(raw_ostream &OS, const Memory::ProtectionFlags &PF) { 36 | assert((PF & ~(Memory::MF_READ | Memory::MF_WRITE | Memory::MF_EXEC)) == 0 && 37 | "Unrecognized flags"); 38 | 39 | return OS << (PF & Memory::MF_READ ? 'R' : '-') 40 | << (PF & Memory::MF_WRITE ? 'W' : '-') 41 | << (PF & Memory::MF_EXEC ? 'X' : '-'); 42 | } 43 | 44 | raw_ostream &operator<<(raw_ostream &OS, const MemoryBlock &MB) { 45 | return OS << "[ " << MB.base() << " .. " 46 | << (void *)((char *)MB.base() + MB.allocatedSize()) << " ] (" 47 | << MB.allocatedSize() << " bytes)"; 48 | } 49 | 50 | } // end namespace sys 51 | } // end namespace llvm 52 | 53 | #endif // ifndef NDEBUG 54 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/MemoryBufferRef.cpp: -------------------------------------------------------------------------------- 1 | //===- MemoryBufferRef.cpp - Memory Buffer Reference ----------------------===// 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 | // This file implements the MemoryBufferRef interface. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #include "llvm/Support/MemoryBufferRef.h" 14 | #include "llvm/Support/MemoryBuffer.h" 15 | 16 | using namespace llvm; 17 | 18 | MemoryBufferRef::MemoryBufferRef(const MemoryBuffer &Buffer) 19 | : Buffer(Buffer.getBuffer()), Identifier(Buffer.getBufferIdentifier()) {} 20 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/Optional.cpp: -------------------------------------------------------------------------------- 1 | //===- Optional.cpp - Optional values ---------------------------*- C++ -*-===// 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/ADT/Optional.h" 10 | #include "llvm/Support/raw_ostream.h" 11 | 12 | llvm::raw_ostream &llvm::operator<<(raw_ostream &OS, NoneType) { 13 | return OS << "None"; 14 | } 15 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/PluginLoader.cpp: -------------------------------------------------------------------------------- 1 | //===-- PluginLoader.cpp - Implement -load command line option ------------===// 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 | // This file implements the -load command line option handler. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #define DONT_GET_PLUGIN_LOADER_OPTION 14 | #include "llvm/Support/PluginLoader.h" 15 | #include "llvm/Support/DynamicLibrary.h" 16 | #include "llvm/Support/ManagedStatic.h" 17 | #include "llvm/Support/Mutex.h" 18 | #include "llvm/Support/raw_ostream.h" 19 | #include 20 | using namespace llvm; 21 | 22 | static ManagedStatic > Plugins; 23 | static ManagedStatic > PluginsLock; 24 | 25 | void PluginLoader::operator=(const std::string &Filename) { 26 | sys::SmartScopedLock Lock(*PluginsLock); 27 | std::string Error; 28 | if (sys::DynamicLibrary::LoadLibraryPermanently(Filename.c_str(), &Error)) { 29 | errs() << "Error opening '" << Filename << "': " << Error 30 | << "\n -load request ignored.\n"; 31 | } else { 32 | Plugins->push_back(Filename); 33 | } 34 | } 35 | 36 | unsigned PluginLoader::getNumPlugins() { 37 | sys::SmartScopedLock Lock(*PluginsLock); 38 | return Plugins.isConstructed() ? Plugins->size() : 0; 39 | } 40 | 41 | std::string &PluginLoader::getPlugin(unsigned num) { 42 | sys::SmartScopedLock Lock(*PluginsLock); 43 | assert(Plugins.isConstructed() && num < Plugins->size() && 44 | "Asking for an out of bounds plugin"); 45 | return (*Plugins)[num]; 46 | } 47 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/RISCVAttributes.cpp: -------------------------------------------------------------------------------- 1 | //===-- RISCVAttributes.cpp - RISCV Attributes ----------------------------===// 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/Support/RISCVAttributes.h" 10 | 11 | using namespace llvm; 12 | using namespace llvm::RISCVAttrs; 13 | 14 | static const TagNameItem tagData[] = { 15 | {STACK_ALIGN, "Tag_stack_align"}, 16 | {ARCH, "Tag_arch"}, 17 | {UNALIGNED_ACCESS, "Tag_unaligned_access"}, 18 | {PRIV_SPEC, "Tag_priv_spec"}, 19 | {PRIV_SPEC_MINOR, "Tag_priv_spec_minor"}, 20 | {PRIV_SPEC_REVISION, "Tag_priv_spec_revision"}, 21 | }; 22 | 23 | const TagNameMap llvm::RISCVAttrs::RISCVAttributeTags(tagData, 24 | sizeof(tagData) / 25 | sizeof(TagNameItem)); 26 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/ScopedPrinter.cpp: -------------------------------------------------------------------------------- 1 | #include "llvm/Support/ScopedPrinter.h" 2 | 3 | #include "llvm/Support/Format.h" 4 | #include 5 | 6 | using namespace llvm::support; 7 | 8 | namespace llvm { 9 | 10 | raw_ostream &operator<<(raw_ostream &OS, const HexNumber &Value) { 11 | OS << "0x" << to_hexString(Value.Value); 12 | return OS; 13 | } 14 | 15 | const std::string to_hexString(uint64_t Value, bool UpperCase) { 16 | std::string number; 17 | llvm::raw_string_ostream stream(number); 18 | stream << format_hex_no_prefix(Value, 1, UpperCase); 19 | return stream.str(); 20 | } 21 | 22 | void ScopedPrinter::printBinaryImpl(StringRef Label, StringRef Str, 23 | ArrayRef Data, bool Block, 24 | uint32_t StartOffset) { 25 | if (Data.size() > 16) 26 | Block = true; 27 | 28 | if (Block) { 29 | startLine() << Label; 30 | if (!Str.empty()) 31 | OS << ": " << Str; 32 | OS << " (\n"; 33 | if (!Data.empty()) 34 | OS << format_bytes_with_ascii(Data, StartOffset, 16, 4, 35 | (IndentLevel + 1) * 2, true) 36 | << "\n"; 37 | startLine() << ")\n"; 38 | } else { 39 | startLine() << Label << ":"; 40 | if (!Str.empty()) 41 | OS << " " << Str; 42 | OS << " (" << format_bytes(Data, None, Data.size(), 1, 0, true) << ")\n"; 43 | } 44 | } 45 | 46 | } // namespace llvm 47 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/StringSaver.cpp: -------------------------------------------------------------------------------- 1 | //===-- StringSaver.cpp ---------------------------------------------------===// 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/Support/StringSaver.h" 10 | 11 | using namespace llvm; 12 | 13 | StringRef StringSaver::save(StringRef S) { 14 | char *P = Alloc.Allocate(S.size() + 1); 15 | if (!S.empty()) 16 | memcpy(P, S.data(), S.size()); 17 | P[S.size()] = '\0'; 18 | return StringRef(P, S.size()); 19 | } 20 | 21 | StringRef UniqueStringSaver::save(StringRef S) { 22 | auto R = Unique.insert(S); 23 | if (R.second) // cache miss, need to actually save the string 24 | *R.first = Strings.save(S); // safe replacement with equal value 25 | return *R.first; 26 | } 27 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/SystemUtils.cpp: -------------------------------------------------------------------------------- 1 | //===- SystemUtils.cpp - Utilities for low-level system tasks -------------===// 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 | // This file contains functions used to do a variety of low-level, often 10 | // system-specific, tasks. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #include "llvm/Support/SystemUtils.h" 15 | #include "llvm/Support/raw_ostream.h" 16 | using namespace llvm; 17 | 18 | bool llvm::CheckBitcodeOutputToConsole(raw_ostream &stream_to_check) { 19 | if (stream_to_check.is_displayed()) { 20 | errs() << "WARNING: You're attempting to print out a bitcode file.\n" 21 | "This is inadvisable as it may cause display problems. If\n" 22 | "you REALLY want to taste LLVM bitcode first-hand, you\n" 23 | "can force output with the `-f' option.\n\n"; 24 | return true; 25 | } 26 | return false; 27 | } 28 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/ThreadLocal.cpp: -------------------------------------------------------------------------------- 1 | //===- ThreadLocal.cpp - Thread Local Data ----------------------*- C++ -*-===// 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 | // This file implements the llvm::sys::ThreadLocal class. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #include "llvm/Support/ThreadLocal.h" 14 | #include "llvm/Config/llvm-config.h" 15 | #include "llvm/Support/Compiler.h" 16 | 17 | //===----------------------------------------------------------------------===// 18 | //=== WARNING: Implementation here must contain only TRULY operating system 19 | //=== independent code. 20 | //===----------------------------------------------------------------------===// 21 | 22 | #if !defined(LLVM_ENABLE_THREADS) || LLVM_ENABLE_THREADS == 0 23 | // Define all methods as no-ops if threading is explicitly disabled 24 | namespace llvm { 25 | using namespace sys; 26 | ThreadLocalImpl::ThreadLocalImpl() : data() { } 27 | ThreadLocalImpl::~ThreadLocalImpl() { } 28 | void ThreadLocalImpl::setInstance(const void* d) { 29 | static_assert(sizeof(d) <= sizeof(data), "size too big"); 30 | void **pd = reinterpret_cast(&data); 31 | *pd = const_cast(d); 32 | } 33 | void *ThreadLocalImpl::getInstance() { 34 | void **pd = reinterpret_cast(&data); 35 | return *pd; 36 | } 37 | void ThreadLocalImpl::removeInstance() { 38 | setInstance(nullptr); 39 | } 40 | } 41 | #elif defined(LLVM_ON_UNIX) 42 | #include "Unix/ThreadLocal.inc" 43 | #elif defined( _WIN32) 44 | #include "Windows/ThreadLocal.inc" 45 | #else 46 | #warning Neither LLVM_ON_UNIX nor _WIN32 set in Support/ThreadLocal.cpp 47 | #endif 48 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/ToolOutputFile.cpp: -------------------------------------------------------------------------------- 1 | //===--- ToolOutputFile.cpp - Implement the ToolOutputFile class --------===// 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 | // This implements the ToolOutputFile class. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #include "llvm/Support/ToolOutputFile.h" 14 | #include "llvm/Support/FileSystem.h" 15 | #include "llvm/Support/Signals.h" 16 | using namespace llvm; 17 | 18 | static bool isStdout(StringRef Filename) { return Filename == "-"; } 19 | 20 | ToolOutputFile::CleanupInstaller::CleanupInstaller(StringRef Filename) 21 | : Filename(std::string(Filename)), Keep(false) { 22 | // Arrange for the file to be deleted if the process is killed. 23 | if (!isStdout(Filename)) 24 | sys::RemoveFileOnSignal(Filename); 25 | } 26 | 27 | ToolOutputFile::CleanupInstaller::~CleanupInstaller() { 28 | if (isStdout(Filename)) 29 | return; 30 | 31 | // Delete the file if the client hasn't told us not to. 32 | if (!Keep) 33 | sys::fs::remove(Filename); 34 | 35 | // Ok, the file is successfully written and closed, or deleted. There's no 36 | // further need to clean it up on signals. 37 | sys::DontRemoveFileOnSignal(Filename); 38 | } 39 | 40 | ToolOutputFile::ToolOutputFile(StringRef Filename, std::error_code &EC, 41 | sys::fs::OpenFlags Flags) 42 | : Installer(Filename) { 43 | if (isStdout(Filename)) { 44 | OS = &outs(); 45 | EC = std::error_code(); 46 | return; 47 | } 48 | OSHolder.emplace(Filename, EC, Flags); 49 | OS = OSHolder.getPointer(); 50 | // If open fails, no cleanup is needed. 51 | if (EC) 52 | Installer.Keep = true; 53 | } 54 | 55 | ToolOutputFile::ToolOutputFile(StringRef Filename, int FD) 56 | : Installer(Filename) { 57 | OSHolder.emplace(FD, true); 58 | OS = OSHolder.getPointer(); 59 | } 60 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/Unix/COM.inc: -------------------------------------------------------------------------------- 1 | //===- llvm/Support/Unix/COM.inc - Unix COM Implementation -----*- C++ -*-===// 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 | // This file implements the Unix portion of COM support. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | //===----------------------------------------------------------------------===// 14 | //=== WARNING: Implementation here must contain only generic UNIX code that 15 | //=== is guaranteed to work on *all* UNIX variants. 16 | //===----------------------------------------------------------------------===// 17 | 18 | namespace llvm { 19 | namespace sys { 20 | 21 | InitializeCOMRAII::InitializeCOMRAII(COMThreadingMode Threading, 22 | bool SpeedOverMemory) {} 23 | 24 | InitializeCOMRAII::~InitializeCOMRAII() {} 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/Unix/README.txt: -------------------------------------------------------------------------------- 1 | llvm/lib/Support/Unix README 2 | =========================== 3 | 4 | This directory provides implementations of the lib/System classes that 5 | are common to two or more variants of UNIX. For example, the directory 6 | structure underneath this directory could look like this: 7 | 8 | Unix - only code that is truly generic to all UNIX platforms 9 | Posix - code that is specific to Posix variants of UNIX 10 | SUS - code that is specific to the Single Unix Specification 11 | SysV - code that is specific to System V variants of UNIX 12 | 13 | As a rule, only those directories actually needing to be created should be 14 | created. Also, further subdirectories could be created to reflect versions of 15 | the various standards. For example, under SUS there could be v1, v2, and v3 16 | subdirectories to reflect the three major versions of SUS. 17 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/Unix/Watchdog.inc: -------------------------------------------------------------------------------- 1 | //===--- Unix/Watchdog.inc - Unix Watchdog Implementation -------*- C++ -*-===// 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 | // This file provides the generic Unix implementation of the Watchdog class. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #include "llvm/Config/config.h" 14 | 15 | #ifdef HAVE_UNISTD_H 16 | #include 17 | #endif 18 | 19 | namespace llvm { 20 | namespace sys { 21 | Watchdog::Watchdog(unsigned int seconds) { 22 | #ifdef HAVE_UNISTD_H 23 | alarm(seconds); 24 | #endif 25 | } 26 | 27 | Watchdog::~Watchdog() { 28 | #ifdef HAVE_UNISTD_H 29 | alarm(0); 30 | #endif 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/Valgrind.cpp: -------------------------------------------------------------------------------- 1 | //===-- Valgrind.cpp - Implement Valgrind communication ---------*- C++ -*-===// 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 | // Defines Valgrind communication methods, if HAVE_VALGRIND_VALGRIND_H is 10 | // defined. If we have valgrind.h but valgrind isn't running, its macros are 11 | // no-ops. 12 | // 13 | //===----------------------------------------------------------------------===// 14 | 15 | #include "llvm/Support/Valgrind.h" 16 | #include "llvm/Config/config.h" 17 | #include 18 | 19 | #if HAVE_VALGRIND_VALGRIND_H 20 | #include 21 | 22 | static bool InitNotUnderValgrind() { 23 | return !RUNNING_ON_VALGRIND; 24 | } 25 | 26 | // This bool is negated from what we'd expect because code may run before it 27 | // gets initialized. If that happens, it will appear to be 0 (false), and we 28 | // want that to cause the rest of the code in this file to run the 29 | // Valgrind-provided macros. 30 | static const bool NotUnderValgrind = InitNotUnderValgrind(); 31 | 32 | bool llvm::sys::RunningOnValgrind() { 33 | if (NotUnderValgrind) 34 | return false; 35 | return RUNNING_ON_VALGRIND; 36 | } 37 | 38 | void llvm::sys::ValgrindDiscardTranslations(const void *Addr, size_t Len) { 39 | if (NotUnderValgrind) 40 | return; 41 | 42 | VALGRIND_DISCARD_TRANSLATIONS(Addr, Len); 43 | } 44 | 45 | #else // !HAVE_VALGRIND_VALGRIND_H 46 | 47 | bool llvm::sys::RunningOnValgrind() { 48 | return false; 49 | } 50 | 51 | void llvm::sys::ValgrindDiscardTranslations(const void *Addr, size_t Len) { 52 | } 53 | 54 | #endif // !HAVE_VALGRIND_VALGRIND_H 55 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/Watchdog.cpp: -------------------------------------------------------------------------------- 1 | //===---- Watchdog.cpp - Implement Watchdog ---------------------*- C++ -*-===// 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 | // This file implements the Watchdog class. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #include "llvm/Support/Watchdog.h" 14 | #include "llvm/Config/llvm-config.h" 15 | 16 | // Include the platform-specific parts of this class. 17 | #ifdef LLVM_ON_UNIX 18 | #include "Unix/Watchdog.inc" 19 | #endif 20 | #ifdef _WIN32 21 | #include "Windows/Watchdog.inc" 22 | #endif 23 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/Windows/COM.inc: -------------------------------------------------------------------------------- 1 | //==- llvm/Support/Windows/COM.inc - Windows COM Implementation -*- C++ -*-===// 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 | // This file implements the Windows portion of COM support. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | //===----------------------------------------------------------------------===// 14 | //=== WARNING: Implementation here must contain only Windows code. 15 | //===----------------------------------------------------------------------===// 16 | 17 | #include 18 | 19 | namespace llvm { 20 | namespace sys { 21 | 22 | InitializeCOMRAII::InitializeCOMRAII(COMThreadingMode Threading, 23 | bool SpeedOverMemory) { 24 | DWORD Coinit = 0; 25 | if (Threading == COMThreadingMode::SingleThreaded) 26 | Coinit |= COINIT_APARTMENTTHREADED; 27 | else 28 | Coinit |= COINIT_MULTITHREADED; 29 | if (SpeedOverMemory) 30 | Coinit |= COINIT_SPEED_OVER_MEMORY; 31 | ::CoInitializeEx(nullptr, Coinit); 32 | } 33 | 34 | InitializeCOMRAII::~InitializeCOMRAII() { ::CoUninitialize(); } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/Windows/Host.inc: -------------------------------------------------------------------------------- 1 | //===- llvm/Support/Win32/Host.inc ------------------------------*- C++ -*-===// 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 | // This file implements the Win32 Host support. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #include "llvm/Support/Windows/WindowsSupport.h" 14 | #include 15 | #include 16 | 17 | using namespace llvm; 18 | 19 | static std::string updateTripleOSVersion(std::string Triple) { 20 | return Triple; 21 | } 22 | 23 | std::string sys::getDefaultTargetTriple() { 24 | const char *Triple = LLVM_DEFAULT_TARGET_TRIPLE; 25 | 26 | // Override the default target with an environment variable named by LLVM_TARGET_TRIPLE_ENV. 27 | #if defined(LLVM_TARGET_TRIPLE_ENV) 28 | if (const char *EnvTriple = std::getenv(LLVM_TARGET_TRIPLE_ENV)) 29 | Triple = EnvTriple; 30 | #endif 31 | 32 | return Triple; 33 | } 34 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/Windows/ThreadLocal.inc: -------------------------------------------------------------------------------- 1 | //= llvm/Support/Win32/ThreadLocal.inc - Win32 Thread Local Data -*- C++ -*-===// 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 | // This file implements the Win32 specific (non-pthread) ThreadLocal class. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | //===----------------------------------------------------------------------===// 14 | //=== WARNING: Implementation here must contain only generic Win32 code that 15 | //=== is guaranteed to work on *all* Win32 variants. 16 | //===----------------------------------------------------------------------===// 17 | 18 | #include "llvm/Support/Windows/WindowsSupport.h" 19 | #include "llvm/Support/ThreadLocal.h" 20 | 21 | namespace llvm { 22 | 23 | sys::ThreadLocalImpl::ThreadLocalImpl() : data() { 24 | static_assert(sizeof(DWORD) <= sizeof(data), "size too big"); 25 | DWORD* tls = reinterpret_cast(&data); 26 | *tls = TlsAlloc(); 27 | assert(*tls != TLS_OUT_OF_INDEXES); 28 | } 29 | 30 | sys::ThreadLocalImpl::~ThreadLocalImpl() { 31 | DWORD* tls = reinterpret_cast(&data); 32 | TlsFree(*tls); 33 | } 34 | 35 | void *sys::ThreadLocalImpl::getInstance() { 36 | DWORD* tls = reinterpret_cast(&data); 37 | return TlsGetValue(*tls); 38 | } 39 | 40 | void sys::ThreadLocalImpl::setInstance(const void* d){ 41 | DWORD* tls = reinterpret_cast(&data); 42 | int errorcode = TlsSetValue(*tls, const_cast(d)); 43 | assert(errorcode != 0); 44 | (void)errorcode; 45 | } 46 | 47 | void sys::ThreadLocalImpl::removeInstance() { 48 | setInstance(0); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/Windows/Watchdog.inc: -------------------------------------------------------------------------------- 1 | //===--- Windows/Watchdog.inc - Windows Watchdog Implementation -*- C++ -*-===// 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 | // This file provides the generic Windows implementation of the Watchdog class. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | // TODO: implement. 14 | // Currently this is only used by PrettyStackTrace which is also unimplemented 15 | // on Windows. Roughly, a Windows implementation would use CreateWaitableTimer 16 | // and a second thread to run the TimerAPCProc. 17 | 18 | namespace llvm { 19 | namespace sys { 20 | Watchdog::Watchdog(unsigned int seconds) {} 21 | Watchdog::~Watchdog() {} 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/circular_raw_ostream.cpp: -------------------------------------------------------------------------------- 1 | //===- circular_raw_ostream.cpp - Implement circular_raw_ostream ----------===// 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 | // This implements support for circular buffered streams. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #include "llvm/Support/circular_raw_ostream.h" 14 | #include 15 | using namespace llvm; 16 | 17 | void circular_raw_ostream::write_impl(const char *Ptr, size_t Size) { 18 | if (BufferSize == 0) { 19 | TheStream->write(Ptr, Size); 20 | return; 21 | } 22 | 23 | // Write into the buffer, wrapping if necessary. 24 | while (Size != 0) { 25 | unsigned Bytes = 26 | std::min(unsigned(Size), unsigned(BufferSize - (Cur - BufferArray))); 27 | memcpy(Cur, Ptr, Bytes); 28 | Size -= Bytes; 29 | Cur += Bytes; 30 | if (Cur == BufferArray + BufferSize) { 31 | // Reset the output pointer to the start of the buffer. 32 | Cur = BufferArray; 33 | Filled = true; 34 | } 35 | } 36 | } 37 | 38 | void circular_raw_ostream::flushBufferWithBanner() { 39 | if (BufferSize != 0) { 40 | // Write out the buffer 41 | TheStream->write(Banner, std::strlen(Banner)); 42 | flushBuffer(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/raw_os_ostream.cpp: -------------------------------------------------------------------------------- 1 | //===--- raw_os_ostream.cpp - Implement the raw_os_ostream class ----------===// 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 | // This implements support adapting raw_ostream to std::ostream. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #include "llvm/Support/raw_os_ostream.h" 14 | #include 15 | using namespace llvm; 16 | 17 | //===----------------------------------------------------------------------===// 18 | // raw_os_ostream 19 | //===----------------------------------------------------------------------===// 20 | 21 | raw_os_ostream::~raw_os_ostream() { 22 | flush(); 23 | } 24 | 25 | void raw_os_ostream::write_impl(const char *Ptr, size_t Size) { 26 | OS.write(Ptr, Size); 27 | } 28 | 29 | uint64_t raw_os_ostream::current_pos() const { return OS.tellp(); } 30 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/lib/Support/regstrlcpy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This code is derived from OpenBSD's libc, original license follows: 3 | * 4 | * Copyright (c) 1998 Todd C. Miller 5 | * 6 | * Permission to use, copy, modify, and distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | #include 20 | #include 21 | 22 | #include "regex_impl.h" 23 | /* 24 | * Copy src to string dst of size siz. At most siz-1 characters 25 | * will be copied. Always NUL terminates (unless siz == 0). 26 | * Returns strlen(src); if retval >= siz, truncation occurred. 27 | */ 28 | size_t 29 | llvm_strlcpy(char *dst, const char *src, size_t siz) 30 | { 31 | char *d = dst; 32 | const char *s = src; 33 | size_t n = siz; 34 | 35 | /* Copy as many bytes as will fit */ 36 | if (n != 0) { 37 | while (--n != 0) { 38 | if ((*d++ = *s++) == '\0') 39 | break; 40 | } 41 | } 42 | 43 | /* Not enough room in dst, add NUL and traverse rest of src */ 44 | if (n == 0) { 45 | if (siz != 0) 46 | *d = '\0'; /* NUL-terminate dst */ 47 | while (*s++) 48 | ; 49 | } 50 | 51 | return(s - src - 1); /* count does not include NUL */ 52 | } 53 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/libffi/common/include/ffi.h: -------------------------------------------------------------------------------- 1 | #ifdef __arm64__ 2 | 3 | #include "ffi_arm64.h" 4 | 5 | 6 | #endif 7 | #ifdef __i386__ 8 | 9 | #include 10 | 11 | 12 | #endif 13 | #ifdef __arm__ 14 | 15 | #include "ffi_armv7.h" 16 | 17 | 18 | #endif 19 | #ifdef __x86_64__ 20 | 21 | #include "ffi_x86_64.h" 22 | 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/libffi/common/include/fficonfig.h: -------------------------------------------------------------------------------- 1 | #ifdef __arm64__ 2 | 3 | #include "fficonfig_arm64.h" 4 | 5 | 6 | #endif 7 | #ifdef __i386__ 8 | 9 | #include 10 | 11 | 12 | #endif 13 | #ifdef __arm__ 14 | 15 | #include "fficonfig_armv7.h" 16 | 17 | 18 | #endif 19 | #ifdef __x86_64__ 20 | 21 | #include "fficonfig_x86_64.h" 22 | 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/libffi/common/include/ffitarget.h: -------------------------------------------------------------------------------- 1 | #ifdef __arm64__ 2 | 3 | #include "ffitarget_arm64.h" 4 | 5 | 6 | #endif 7 | #ifdef __i386__ 8 | 9 | #include 10 | 11 | 12 | #endif 13 | #ifdef __arm__ 14 | 15 | #include "ffitarget_armv7.h" 16 | 17 | 18 | #endif 19 | #ifdef __x86_64__ 20 | 21 | #include "ffitarget_x86_64.h" 22 | 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/libffi/ios/src/arm/internal.h: -------------------------------------------------------------------------------- 1 | #ifdef __arm__ 2 | 3 | #define ARM_TYPE_VFP_S 0 4 | #define ARM_TYPE_VFP_D 1 5 | #define ARM_TYPE_VFP_N 2 6 | #define ARM_TYPE_INT64 3 7 | #define ARM_TYPE_INT 4 8 | #define ARM_TYPE_VOID 5 9 | #define ARM_TYPE_STRUCT 6 10 | 11 | 12 | #endif -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/libffi/ios/src/x86/asmnames.h: -------------------------------------------------------------------------------- 1 | #ifdef __x86_64__ 2 | 3 | #ifndef ASMNAMES_H 4 | #define ASMNAMES_H 5 | 6 | #define C2(X, Y) X ## Y 7 | #define C1(X, Y) C2(X, Y) 8 | #ifdef __USER_LABEL_PREFIX__ 9 | # define C(X) C1(__USER_LABEL_PREFIX__, X) 10 | #else 11 | # define C(X) X 12 | #endif 13 | 14 | #ifdef __APPLE__ 15 | # define L(X) C1(L, X) 16 | #else 17 | # define L(X) C1(.L, X) 18 | #endif 19 | 20 | #if defined(__ELF__) && defined(__PIC__) 21 | # define PLT(X) X@PLT 22 | #else 23 | # define PLT(X) X 24 | #endif 25 | 26 | #ifdef __ELF__ 27 | # define ENDF(X) .type X,@function; .size X, . - X 28 | #else 29 | # define ENDF(X) 30 | #endif 31 | 32 | #endif /* ASMNAMES_H */ 33 | 34 | 35 | #endif -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/libffi/ios/src/x86/internal.h: -------------------------------------------------------------------------------- 1 | #ifdef __i386__ 2 | 3 | #define X86_RET_FLOAT 0 4 | #define X86_RET_DOUBLE 1 5 | #define X86_RET_LDOUBLE 2 6 | #define X86_RET_SINT8 3 7 | #define X86_RET_SINT16 4 8 | #define X86_RET_UINT8 5 9 | #define X86_RET_UINT16 6 10 | #define X86_RET_INT64 7 11 | #define X86_RET_INT32 8 12 | #define X86_RET_VOID 9 13 | #define X86_RET_STRUCTPOP 10 14 | #define X86_RET_STRUCTARG 11 15 | #define X86_RET_STRUCT_1B 12 16 | #define X86_RET_STRUCT_2B 13 17 | #define X86_RET_UNUSED14 14 18 | #define X86_RET_UNUSED15 15 19 | 20 | #define X86_RET_TYPE_MASK 15 21 | #define X86_RET_POP_SHIFT 4 22 | 23 | #define R_EAX 0 24 | #define R_EDX 1 25 | #define R_ECX 2 26 | 27 | #ifdef __PCC__ 28 | # define HAVE_FASTCALL 0 29 | #else 30 | # define HAVE_FASTCALL 1 31 | #endif 32 | 33 | 34 | #endif -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/libffi/ios/src/x86/internal64.h: -------------------------------------------------------------------------------- 1 | #ifdef __x86_64__ 2 | 3 | #define UNIX64_RET_VOID 0 4 | #define UNIX64_RET_UINT8 1 5 | #define UNIX64_RET_UINT16 2 6 | #define UNIX64_RET_UINT32 3 7 | #define UNIX64_RET_SINT8 4 8 | #define UNIX64_RET_SINT16 5 9 | #define UNIX64_RET_SINT32 6 10 | #define UNIX64_RET_INT64 7 11 | #define UNIX64_RET_XMM32 8 12 | #define UNIX64_RET_XMM64 9 13 | #define UNIX64_RET_X87 10 14 | #define UNIX64_RET_X87_2 11 15 | #define UNIX64_RET_ST_XMM0_RAX 12 16 | #define UNIX64_RET_ST_RAX_XMM0 13 17 | #define UNIX64_RET_ST_XMM0_XMM1 14 18 | #define UNIX64_RET_ST_RAX_RDX 15 19 | 20 | #define UNIX64_RET_LAST 15 21 | 22 | #define UNIX64_FLAG_RET_IN_MEM (1 << 10) 23 | #define UNIX64_FLAG_XMM_ARGS (1 << 11) 24 | #define UNIX64_SIZE_SHIFT 12 25 | 26 | 27 | #endif -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/llvm-c/ErrorHandling.h: -------------------------------------------------------------------------------- 1 | /*===-- llvm-c/ErrorHandling.h - Error Handling C Interface -------*- C -*-===*\ 2 | |* *| 3 | |* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| 4 | |* Exceptions. *| 5 | |* See https://llvm.org/LICENSE.txt for license information. *| 6 | |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| 7 | |* *| 8 | |*===----------------------------------------------------------------------===*| 9 | |* *| 10 | |* This file defines the C interface to LLVM's error handling mechanism. *| 11 | |* *| 12 | \*===----------------------------------------------------------------------===*/ 13 | 14 | #ifndef LLVM_C_ERROR_HANDLING_H 15 | #define LLVM_C_ERROR_HANDLING_H 16 | 17 | #include "llvm-c/ExternC.h" 18 | 19 | LLVM_C_EXTERN_C_BEGIN 20 | 21 | typedef void (*LLVMFatalErrorHandler)(const char *Reason); 22 | 23 | /** 24 | * Install a fatal error handler. By default, if LLVM detects a fatal error, it 25 | * will call exit(1). This may not be appropriate in many contexts. For example, 26 | * doing exit(1) will bypass many crash reporting/tracing system tools. This 27 | * function allows you to install a callback that will be invoked prior to the 28 | * call to exit(1). 29 | */ 30 | void LLVMInstallFatalErrorHandler(LLVMFatalErrorHandler Handler); 31 | 32 | /** 33 | * Reset the fatal error handler. This resets LLVM's fatal error handling 34 | * behavior to the default. 35 | */ 36 | void LLVMResetFatalErrorHandler(void); 37 | 38 | /** 39 | * Enable LLVM's built-in stack trace code. This intercepts the OS's crash 40 | * signals and prints which component of LLVM you were in at the time if the 41 | * crash. 42 | */ 43 | void LLVMEnablePrettyStackTrace(void); 44 | 45 | LLVM_C_EXTERN_C_END 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/llvm-c/ExternC.h: -------------------------------------------------------------------------------- 1 | /*===- llvm-c/ExternC.h - Wrapper for 'extern "C"' ----------------*- C -*-===*\ 2 | |* *| 3 | |* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| 4 | |* Exceptions. *| 5 | |* See https://llvm.org/LICENSE.txt for license information. *| 6 | |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| 7 | |* *| 8 | |*===----------------------------------------------------------------------===*| 9 | |* *| 10 | |* This file defines an 'extern "C"' wrapper *| 11 | |* *| 12 | \*===----------------------------------------------------------------------===*/ 13 | 14 | #ifndef LLVM_C_EXTERN_C_H 15 | #define LLVM_C_EXTERN_C_H 16 | 17 | #ifdef __clang__ 18 | #define LLVM_C_STRICT_PROTOTYPES_BEGIN \ 19 | _Pragma("clang diagnostic push") \ 20 | _Pragma("clang diagnostic error \"-Wstrict-prototypes\"") 21 | #define LLVM_C_STRICT_PROTOTYPES_END _Pragma("clang diagnostic pop") 22 | #else 23 | #define LLVM_C_STRICT_PROTOTYPES_BEGIN 24 | #define LLVM_C_STRICT_PROTOTYPES_END 25 | #endif 26 | 27 | #ifdef __cplusplus 28 | #define LLVM_C_EXTERN_C_BEGIN \ 29 | extern "C" { \ 30 | LLVM_C_STRICT_PROTOTYPES_BEGIN 31 | #define LLVM_C_EXTERN_C_END \ 32 | LLVM_C_STRICT_PROTOTYPES_END \ 33 | } 34 | #else 35 | #define LLVM_C_EXTERN_C_BEGIN LLVM_C_STRICT_PROTOTYPES_BEGIN 36 | #define LLVM_C_EXTERN_C_END LLVM_C_STRICT_PROTOTYPES_END 37 | #endif 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/llvm-c/IRReader.h: -------------------------------------------------------------------------------- 1 | /*===-- llvm-c/IRReader.h - IR Reader C Interface -----------------*- C -*-===*\ 2 | |* *| 3 | |* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| 4 | |* Exceptions. *| 5 | |* See https://llvm.org/LICENSE.txt for license information. *| 6 | |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| 7 | |* *| 8 | |*===----------------------------------------------------------------------===*| 9 | |* *| 10 | |* This file defines the C interface to the IR Reader. *| 11 | |* *| 12 | \*===----------------------------------------------------------------------===*/ 13 | 14 | #ifndef LLVM_C_IRREADER_H 15 | #define LLVM_C_IRREADER_H 16 | 17 | #include "llvm-c/ExternC.h" 18 | #include "llvm-c/Types.h" 19 | 20 | LLVM_C_EXTERN_C_BEGIN 21 | 22 | /** 23 | * Read LLVM IR from a memory buffer and convert it into an in-memory Module 24 | * object. Returns 0 on success. 25 | * Optionally returns a human-readable description of any errors that 26 | * occurred during parsing IR. OutMessage must be disposed with 27 | * LLVMDisposeMessage. 28 | * 29 | * @see llvm::ParseIR() 30 | */ 31 | LLVMBool LLVMParseIRInContext(LLVMContextRef ContextRef, 32 | LLVMMemoryBufferRef MemBuf, LLVMModuleRef *OutM, 33 | char **OutMessage); 34 | 35 | LLVM_C_EXTERN_C_END 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/llvm-c/Linker.h: -------------------------------------------------------------------------------- 1 | /*===-- llvm-c/Linker.h - Module Linker C Interface -------------*- C++ -*-===*\ 2 | |* *| 3 | |* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| 4 | |* Exceptions. *| 5 | |* See https://llvm.org/LICENSE.txt for license information. *| 6 | |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| 7 | |* *| 8 | |*===----------------------------------------------------------------------===*| 9 | |* *| 10 | |* This file defines the C interface to the module/file/archive linker. *| 11 | |* *| 12 | \*===----------------------------------------------------------------------===*/ 13 | 14 | #ifndef LLVM_C_LINKER_H 15 | #define LLVM_C_LINKER_H 16 | 17 | #include "llvm-c/ExternC.h" 18 | #include "llvm-c/Types.h" 19 | 20 | LLVM_C_EXTERN_C_BEGIN 21 | 22 | /* This enum is provided for backwards-compatibility only. It has no effect. */ 23 | typedef enum { 24 | LLVMLinkerDestroySource = 0, /* This is the default behavior. */ 25 | LLVMLinkerPreserveSource_Removed = 1 /* This option has been deprecated and 26 | should not be used. */ 27 | } LLVMLinkerMode; 28 | 29 | /* Links the source module into the destination module. The source module is 30 | * destroyed. 31 | * The return value is true if an error occurred, false otherwise. 32 | * Use the diagnostic handler to get any diagnostic message. 33 | */ 34 | LLVMBool LLVMLinkModules2(LLVMModuleRef Dest, LLVMModuleRef Src); 35 | 36 | LLVM_C_EXTERN_C_END 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/llvm-c/Transforms/AggressiveInstCombine.h: -------------------------------------------------------------------------------- 1 | /*===-- AggressiveInstCombine.h ---------------------------------*- C++ -*-===*\ 2 | |* *| 3 | |* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| 4 | |* Exceptions. *| 5 | |* See https://llvm.org/LICENSE.txt for license information. *| 6 | |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| 7 | |* *| 8 | |*===----------------------------------------------------------------------===*| 9 | |* *| 10 | |* This header declares the C interface to libLLVMAggressiveInstCombine.a, *| 11 | |* which combines instructions to form fewer, simple IR instructions. *| 12 | |* *| 13 | \*===----------------------------------------------------------------------===*/ 14 | 15 | #ifndef LLVM_C_TRANSFORMS_AGGRESSIVEINSTCOMBINE_H 16 | #define LLVM_C_TRANSFORMS_AGGRESSIVEINSTCOMBINE_H 17 | 18 | #include "llvm-c/ExternC.h" 19 | #include "llvm-c/Types.h" 20 | 21 | LLVM_C_EXTERN_C_BEGIN 22 | 23 | /** 24 | * @defgroup LLVMCTransformsAggressiveInstCombine Aggressive Instruction Combining transformations 25 | * @ingroup LLVMCTransforms 26 | * 27 | * @{ 28 | */ 29 | 30 | /** See llvm::createAggressiveInstCombinerPass function. */ 31 | void LLVMAddAggressiveInstCombinerPass(LLVMPassManagerRef PM); 32 | 33 | /** 34 | * @} 35 | */ 36 | 37 | LLVM_C_EXTERN_C_END 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/llvm-c/Transforms/InstCombine.h: -------------------------------------------------------------------------------- 1 | /*===-- Scalar.h - Scalar Transformation Library C Interface ----*- C++ -*-===*\ 2 | |* *| 3 | |* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| 4 | |* Exceptions. *| 5 | |* See https://llvm.org/LICENSE.txt for license information. *| 6 | |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| 7 | |* *| 8 | |*===----------------------------------------------------------------------===*| 9 | |* *| 10 | |* This header declares the C interface to libLLVMInstCombine.a, which *| 11 | |* combines instructions to form fewer, simple IR instructions. *| 12 | |* *| 13 | \*===----------------------------------------------------------------------===*/ 14 | 15 | #ifndef LLVM_C_TRANSFORMS_INSTCOMBINE_H 16 | #define LLVM_C_TRANSFORMS_INSTCOMBINE_H 17 | 18 | #include "llvm-c/ExternC.h" 19 | #include "llvm-c/Types.h" 20 | 21 | LLVM_C_EXTERN_C_BEGIN 22 | 23 | /** 24 | * @defgroup LLVMCTransformsInstCombine Instruction Combining transformations 25 | * @ingroup LLVMCTransforms 26 | * 27 | * @{ 28 | */ 29 | 30 | /** See llvm::createInstructionCombiningPass function. */ 31 | void LLVMAddInstructionCombiningPass(LLVMPassManagerRef PM); 32 | 33 | /** 34 | * @} 35 | */ 36 | 37 | LLVM_C_EXTERN_C_END 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreter/llvm/llvm-c/module.modulemap: -------------------------------------------------------------------------------- 1 | module LLVM_C { 2 | umbrella "." 3 | module * { export * } 4 | } 5 | -------------------------------------------------------------------------------- /BitCodeInterpreter/BitCodeInterpreterUserDemo.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // BitCodeInterpreterUserDemo.hpp 3 | // BitCodeInterpreter 4 | // 5 | // Created by jintao on 2021/6/28. 6 | // 7 | 8 | #ifndef BitCodeInterpreterUserDemo_hpp 9 | #define BitCodeInterpreterUserDemo_hpp 10 | 11 | #include 12 | #include "llvm-c/IRReader.h" 13 | #include "IRReader/IRReader.h" 14 | #include "SourceMgr.h" 15 | #include "Module.h" 16 | #include "LLVMContext.h" 17 | #include "ExecutionEngine.h" 18 | 19 | using namespace llvm; 20 | 21 | extern "C" int InterpreterMain(const char * irFile, int argc, char **argv, char * const *envp); 22 | 23 | int InterpreterMain(const char * irFile, int argc, char **argv, char * const *envp) { 24 | // 初始化IR文件 25 | SMDiagnostic Err; 26 | LLVMContext Context; 27 | std::unique_ptr Owner = parseIRFile(irFile, Err, Context); 28 | Module *Mod = Owner.get(); 29 | 30 | if (Mod) { 31 | // Mod->dump(); 32 | } 33 | 34 | // 初始化解释器 35 | EngineBuilder builder(std::move(Owner)); 36 | builder.setEngineKind(EngineKind::Interpreter); 37 | 38 | std::unique_ptr EE(builder.create()); 39 | 40 | 41 | // 初始化参数 42 | std::vector inputArgv; 43 | if (argc > 0 && argv != NULL) { 44 | for (int i = 0; argv[i] != NULL; i++) { 45 | inputArgv.push_back(argv[i]); 46 | } 47 | } 48 | 49 | // Run 50 | Function *EntryFn = Mod->getFunction("main"); 51 | EE->runFunctionAsMain(EntryFn, inputArgv, envp); 52 | 53 | return 0; 54 | } 55 | 56 | #endif /* BitCodeInterpreterUserDemo_hpp */ 57 | -------------------------------------------------------------------------------- /BitCodeInterpreter/SceneDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.h 3 | // BitCodeInterpreter 4 | // 5 | // Created by jintao on 2021/6/24. 6 | // 7 | 8 | #import 9 | 10 | @interface SceneDelegate : UIResponder 11 | 12 | @property (strong, nonatomic) UIWindow * window; 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /BitCodeInterpreter/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // BitCodeInterpreter 4 | // 5 | // Created by jintao on 2021/6/24. 6 | // 7 | 8 | #import 9 | 10 | @interface ViewController : UIViewController 11 | 12 | 13 | @end 14 | 15 | -------------------------------------------------------------------------------- /BitCodeInterpreter/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // BitCodeInterpreter 4 | // 5 | // Created by jintao on 2021/6/24. 6 | // 7 | 8 | #import "ViewController.h" 9 | 10 | @interface ViewController () 11 | 12 | @end 13 | 14 | @implementation ViewController 15 | 16 | - (void)viewDidLoad { 17 | [super viewDidLoad]; 18 | // Do any additional setup after loading the view. 19 | } 20 | 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /BitCodeInterpreter/main.bc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TannerJin/BitCodeInterpreter/c9a73f4dc4f99a9f310e0f88370d9407aa93fa97/BitCodeInterpreter/main.bc -------------------------------------------------------------------------------- /BitCodeInterpreter/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // BitCodeInterpreter 4 | // 5 | // Created by jintao on 2021/6/24. 6 | // 7 | 8 | #import 9 | #import "AppDelegate.h" 10 | #import "dlfcn.h" 11 | 12 | extern int InterpreterMain(const char * irFile, int argc, char **argv, char * const *envp); 13 | 14 | int main(int argc, char * argv[]) { 15 | NSString * appDelegateClassName; 16 | @autoreleasepool { 17 | // Setup code that might create autoreleased objects goes here. 18 | appDelegateClassName = NSStringFromClass([AppDelegate class]); 19 | } 20 | 21 | const char *path = [[NSString stringWithFormat:@"%@%s", NSBundle.mainBundle.bundlePath, "/main.bc"] cStringUsingEncoding:NSUTF8StringEncoding]; 22 | printf("IR Path is: %s \n", path); 23 | 24 | // 开始执行 BitCode 25 | InterpreterMain(path, 0, NULL, NULL); 26 | 27 | return UIApplicationMain(argc, argv, nil, appDelegateClassName); 28 | } 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LLVM BitCode 解释器 2 | > 去除了 `JIT` & 只支持 `mach-o` 的 BitCode 解释器 3 | 4 | ## 用来干啥 5 | * Hotfix 6 | * VM Execution 7 | 8 | ## 目前发现问题 9 | * 目前 Interpreter 文件依赖过多,正在优化 10 | 11 | * Bitcode 中自定义的`Objective-C`类,由于没有经过`objc_init`过,`objc`中不存在对应`class`, 计划通过定制处理IR & `objc_registerClassPair` & `sel_registerName` 解决 12 | 13 | 14 | ## 注意 15 | > 全局搜索 `Tanner` 查看定制化处理逻辑 16 | --------------------------------------------------------------------------------