SelectionDAG is a library in LLVM that represents a target-independent DAG of operations, which are used to generate the code for a program. SelectionDAG provides many utility functions to manipulate and analyze the DAG in order to optimize the generated code. One of these functions is getCopyFromReg(), which returns a node that copies a value from a physical register into a virtual register.
Here are some examples of using getCopyFromReg():
// Example 1: Copying a physical register into a virtual register SDValue RegVal = DAG.getCopyFromReg(DAG.getEntryNode(), SDLoc(), PhysReg, VT);
In this example, getCopyFromReg() is used to create a node that copies the value from a physical register (PhysReg) into a virtual register of type VT. The resulting node is attached as a child to the entry node of the DAG.
// Example 2: Copying a physical register into a virtual register with an offset SDValue RegVal = DAG.getCopyFromReg(DAG.getEntryNode(), SDLoc(), PhysReg, VT, Offset);
In this example, getCopyFromReg() is used to create a node that copies the value from a physical register (PhysReg) into a virtual register of type VT, but with a specified offset. This is useful for handling stack frames, where the location of the virtual register is determined by an offset from the stack pointer.
// Example 3: Copying a physical register into multiple virtual registers SDValue RegVals[2]; DAG.getCopyFromReg(DAG.getEntryNode(), SDLoc(), PhysReg, VT, RegVals);
In this example, getCopyFromReg() is used to create two nodes that copy the value from a physical register (PhysReg) into two virtual registers of type VT. The resulting nodes are attached as children to the entry node of the DAG, and the resulting virtual register values are stored in the RegVals array.
The getCopyFromReg() function is part of the SelectionDAG library in LLVM.
C++ (Cpp) SelectionDAG::getCopyFromReg - 30 examples found. These are the top rated real world C++ (Cpp) examples of SelectionDAG::getCopyFromReg extracted from open source projects. You can rate examples to help us improve the quality of examples.