public Value CreateAttributeSingleton(AttributeType type) { if (type.Members.Count != 0) { throw new CompilerBugException(); } var name = "singleton_" + type.GetMangledName(); var attr = LlvmModule.GetNamedGlobal(name); if (attr != null) { goto Ret; } attr = LlvmModule.AddGlobal(type, name); attr.Initializer = LLVMValueRef.CreateConstNamedStruct(type, ReadOnlySpan <LLVMValueRef> .Empty); Ret: return(new Value { Type = type, LlvmValue = attr, }); }
public LLVMValueRef ToLLVMValueRef(LLVMModuleRef module) { LLVMValueRef valRef = IsFunction ? module.GetNamedFunction(SymbolName) : module.GetNamedGlobal(SymbolName); if (Offset != 0 && valRef.Handle != IntPtr.Zero) { var CreatePointer = LLVMTypeRef.CreatePointer(LLVMTypeRef.Int8, 0); var bitCast = LLVMValueRef.CreateConstBitCast(valRef, CreatePointer); LLVMValueRef[] index = new LLVMValueRef[] { LLVMValueRef.CreateConstInt(LLVMTypeRef.Int32, Offset, false) }; valRef = LLVMValueRef.CreateConstGEP(bitCast, index); } return(valRef); }