/// <summary> /// Adds an instruction to this prologue. /// </summary> /// <param name="Instruction">The instruction to add to the prologue.</param> /// <returns>A unique tag that can be used to retrieve the instruction's codegen value.</returns> public UniqueTag AddInstruction(CodeBlock Instruction) { var tag = new UniqueTag(); taggedInstructions.Add(new KeyValuePair <UniqueTag, CodeBlock>(tag, Instruction)); return(tag); }
/// <summary> /// Tags the given break and continue blocks with the given tag. /// </summary> /// <param name="Tag">The tag for a flow block.</param> /// <param name="BreakBlock">The 'break' basic block for the flow block.</param> /// <param name="ContinueBlock">The 'continue' basic block for the flow block.</param> public void TagFlowBlock( UniqueTag Tag, LLVMBasicBlockRef BreakBlock, LLVMBasicBlockRef ContinueBlock) { breakBlocks.Add(Tag, BreakBlock); continueBlocks.Add(Tag, ContinueBlock); }
public IUnmanagedEmitVariable DeclareUnmanagedLocal(UniqueTag Tag, IVariableMember VariableMember) { var alloca = new AllocaBlock(this, VariableMember.VariableType); var valueTag = Prologue.AddInstruction(alloca); var taggedValue = new TaggedValueBlock(this, valueTag, alloca.Type); locals.Add(Tag, taggedValue); return(new AtAddressEmitVariable(taggedValue)); }
public TaggedValueBlock( ICodeGenerator CodeGenerator, UniqueTag Tag, IType Type) { this.codeGen = CodeGenerator; this.Tag = Tag; this.valType = Type; }
/// <summary> /// Creates a branching block from a tag and a Boolean /// that distinguishes between 'break' and 'continue' blocks. /// </summary> /// <param name="CodeGenerator">The code generator that creates the block.</param> /// <param name="Tag">The tag of the target block.</param> /// <param name="IsBreak"><c>true</c> creates a 'break' block, <c>false</c> creates a 'continue' block.</param> public BranchBlock( ICodeGenerator CodeGenerator, UniqueTag Tag, bool IsBreak) { this.codeGen = CodeGenerator; this.Tag = Tag; this.IsBreak = IsBreak; }
/// <summary> /// Creates a tagged flow block from the given tag and body. /// </summary> /// <param name="CodeGenerator">The code generator that creates the block.</param> /// <param name="Tag">A tag to which 'break' and 'continue' blocks can refer.</param> /// <param name="Body">The contents of the block.</param> public TaggedFlowBlock( ICodeGenerator CodeGenerator, UniqueTag Tag, CodeBlock Body) { this.codeGen = CodeGenerator; this.Tag = Tag; this.Body = Body; }
/// <summary> /// Gets or creates the labeled block with the given label. /// </summary> /// <param name="Label">The labeled block's label, as a unique tag.</param> /// <returns>A basic block builder for the labeled block.</returns> public BasicBlockBuilder GetOrCreateLabeledBlock(UniqueTag Label) { BasicBlockBuilder result; if (!labeledBlocks.TryGetValue(Label, out result)) { result = AppendBasicBlock(Label.Name); labeledBlocks[Label] = result; } return(result); }
public IUnmanagedEmitVariable GetUnmanagedLocal(UniqueTag Tag) { TaggedValueBlock address; if (locals.TryGetValue(Tag, out address)) { return(new AtAddressEmitVariable(address)); } else { return(null); } }
public ICodeBlock EmitMarkLabel(UniqueTag Label) { return(new MarkLabelBlock(this, Label)); }
public IEmitVariable GetLocal(UniqueTag Tag) { return(GetUnmanagedLocal(Tag)); }
/// <summary> /// Gets the tagged value with the given tag. /// </summary> /// <param name="Tag">The tag of the value to retrieve.</param> /// <returns>The tagged value.</returns> public LLVMValueRef GetTaggedValue(UniqueTag Tag) { return(taggedValues[Tag]); }
public ICodeBlock EmitBreak(UniqueTag Target) { return(new BranchBlock(this, Target, true)); }
/// <summary> /// Gets the 'continue' basic block for the given tag. /// </summary> /// <param name="Tag">The tag to find a 'continue' basic block for.</param> /// <returns>The 'continue' basic block.</returns> public LLVMBasicBlockRef GetContinueBlock(UniqueTag Tag) { return(continueBlocks[Tag]); }
/// <summary> /// Gets the 'break' basic block for the given tag. /// </summary> /// <param name="Tag">The tag to find a 'break' basic block for.</param> /// <returns>The 'break' basic block.</returns> public LLVMBasicBlockRef GetBreakBlock(UniqueTag Tag) { return(breakBlocks[Tag]); }
public ICodeBlock EmitGotoLabel(UniqueTag Label, ICodeBlock Condition) { return(new BranchLabelBlock(this, Label)); }
public ICodeBlock EmitTagged(UniqueTag Tag, ICodeBlock Contents) { return(new TaggedFlowBlock(this, Tag, (CodeBlock)Contents)); }
private LNode EncodeUniqueTag(UniqueTag tag, UniqueNameMap <UniqueTag> nameMap) { return(Factory.Id(nameMap[tag])); }
public ICodeBlock EmitContinue(UniqueTag Target) { return(new BranchBlock(this, Target, false)); }
public IEmitVariable DeclareLocal(UniqueTag Tag, IVariableMember VariableMember) { return(DeclareUnmanagedLocal(Tag, VariableMember)); }
/// <summary> /// Creates a code block that branches to a basic block with a label. /// </summary> /// <param name="CodeGenerator">The code generator.</param> /// <param name="Label">The label of the basic block to branch to.</param> public BranchLabelBlock(ICodeGenerator CodeGenerator, UniqueTag Label) { this.codeGen = CodeGenerator; this.Label = Label; }
/// <summary> /// Tags the given value with the given tag. /// </summary> /// <param name="Tag">The tag for the value.</param> /// <param name="Value">The value to tag.</param> public void TagValue(UniqueTag Tag, LLVMValueRef Value) { taggedValues.Add(Tag, Value); }