1 //===- DemoteRegToStack.h - Move a virtual reg. to stack --------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file provides the function:
11 // AllocaInst* DemoteRegToStack(Instruction& X):
13 // This function takes a virtual register computed by an
14 // Instruction& X and replaces it with a slot in the stack frame,
15 // allocated via alloca. It has to:
16 // (1) Identify all Phi operations that have X as an operand and
17 // transitively other Phis that use such Phis;
18 // (2) Store all values merged with X via Phi operations to the stack slot;
19 // (3) Load the value from the stack slot just before any use of X or any
20 // of the Phis that were eliminated; and
21 // (4) Delete X and all the Phis, which should all now be dead.
23 // Returns the pointer to the alloca inserted to create a stack slot for X.
25 //===----------------------------------------------------------------------===//
30 AllocaInst *DemoteRegToStack(Instruction &X);