blob: d33055ccb8765b73d84a88d5f400431f69e142bb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
//===-- AMDGPULowerShaderInstructions.cpp - TODO: Add brief description -------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// TODO: Add full description
//
//===----------------------------------------------------------------------===//
#include "AMDGPULowerShaderInstructions.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/Target/TargetInstrInfo.h"
using namespace llvm;
void AMDGPULowerShaderInstructionsPass::preloadRegister(MachineFunction * MF,
const TargetInstrInfo * TII, unsigned physReg, unsigned virtReg) const
{
if (!MRI->isLiveIn(physReg)) {
MRI->addLiveIn(physReg, virtReg);
MachineBasicBlock &EntryMBB = MF->front();
BuildMI(MF->front(), EntryMBB.begin(), DebugLoc(), TII->get(TargetOpcode::COPY),
virtReg)
.addReg(physReg);
} else {
/* We can't mark the same register as preloaded twice, but we still must
* associate virtReg with the correct preloaded register. */
unsigned newReg = MRI->getLiveInVirtReg(physReg);
MRI->replaceRegWith(virtReg, newReg);
}
}
|