コード例 #1
0
        /// <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);
        }
コード例 #2
0
 /// <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);
 }
コード例 #3
0
        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));
        }
コード例 #4
0
 public TaggedValueBlock(
     ICodeGenerator CodeGenerator,
     UniqueTag Tag,
     IType Type)
 {
     this.codeGen = CodeGenerator;
     this.Tag     = Tag;
     this.valType = Type;
 }
コード例 #5
0
ファイル: BranchBlock.cs プロジェクト: jonathanvdc/flame-llvm
 /// <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;
 }
コード例 #6
0
 /// <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;
 }
コード例 #7
0
        /// <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);
        }
コード例 #8
0
        public IUnmanagedEmitVariable GetUnmanagedLocal(UniqueTag Tag)
        {
            TaggedValueBlock address;

            if (locals.TryGetValue(Tag, out address))
            {
                return(new AtAddressEmitVariable(address));
            }
            else
            {
                return(null);
            }
        }
コード例 #9
0
 public ICodeBlock EmitMarkLabel(UniqueTag Label)
 {
     return(new MarkLabelBlock(this, Label));
 }
コード例 #10
0
 public IEmitVariable GetLocal(UniqueTag Tag)
 {
     return(GetUnmanagedLocal(Tag));
 }
コード例 #11
0
 /// <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]);
 }
コード例 #12
0
 public ICodeBlock EmitBreak(UniqueTag Target)
 {
     return(new BranchBlock(this, Target, true));
 }
コード例 #13
0
 /// <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]);
 }
コード例 #14
0
 /// <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]);
 }
コード例 #15
0
 public ICodeBlock EmitGotoLabel(UniqueTag Label, ICodeBlock Condition)
 {
     return(new BranchLabelBlock(this, Label));
 }
コード例 #16
0
 public ICodeBlock EmitTagged(UniqueTag Tag, ICodeBlock Contents)
 {
     return(new TaggedFlowBlock(this, Tag, (CodeBlock)Contents));
 }
コード例 #17
0
 private LNode EncodeUniqueTag(UniqueTag tag, UniqueNameMap <UniqueTag> nameMap)
 {
     return(Factory.Id(nameMap[tag]));
 }
コード例 #18
0
 public ICodeBlock EmitContinue(UniqueTag Target)
 {
     return(new BranchBlock(this, Target, false));
 }
コード例 #19
0
 public IEmitVariable DeclareLocal(UniqueTag Tag, IVariableMember VariableMember)
 {
     return(DeclareUnmanagedLocal(Tag, VariableMember));
 }
コード例 #20
0
 /// <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;
 }
コード例 #21
0
 /// <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);
 }