github.com/llir/llvm@v0.3.6/ir/block_vector.go (about)

     1  package ir
     2  
     3  import (
     4  	"github.com/llir/llvm/ir/value"
     5  )
     6  
     7  // --- [ Vector instructions ] -------------------------------------------------
     8  
     9  // ~~~ [ extractelement ] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    10  
    11  // NewExtractElement appends a new extractelement instruction to the basic block
    12  // based on the given vector and element index.
    13  func (block *Block) NewExtractElement(x, index value.Value) *InstExtractElement {
    14  	inst := NewExtractElement(x, index)
    15  	block.Insts = append(block.Insts, inst)
    16  	return inst
    17  }
    18  
    19  // ~~~ [ insertelement ] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    20  
    21  // NewInsertElement appends a new insertelement instruction to the basic block
    22  // based on the given vector, element and element index.
    23  func (block *Block) NewInsertElement(x, elem, index value.Value) *InstInsertElement {
    24  	inst := NewInsertElement(x, elem, index)
    25  	block.Insts = append(block.Insts, inst)
    26  	return inst
    27  }
    28  
    29  // ~~~ [ shufflevector ] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    30  
    31  // NewShuffleVector appends a new shufflevector instruction to the basic block
    32  // based on the given vectors and shuffle mask.
    33  func (block *Block) NewShuffleVector(x, y, mask value.Value) *InstShuffleVector {
    34  	inst := NewShuffleVector(x, y, mask)
    35  	block.Insts = append(block.Insts, inst)
    36  	return inst
    37  }