AMDGPU: Mark test as XFAIL in expensive_checks builds
[llvm-project.git] / llvm / lib / Target / XCore / XCoreFrameToArgsOffsetElim.cpp
blobaa6bf50d997325ce22402eb283a11dadc5495a95
1 //===-- XCoreFrameToArgsOffsetElim.cpp ----------------------------*- C++ -*-=//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Replace Pseudo FRAME_TO_ARGS_OFFSET with the appropriate real offset.
11 //===----------------------------------------------------------------------===//
13 #include "XCore.h"
14 #include "XCoreInstrInfo.h"
15 #include "XCoreSubtarget.h"
16 #include "llvm/CodeGen/MachineFrameInfo.h"
17 #include "llvm/CodeGen/MachineFunctionPass.h"
18 #include "llvm/Target/TargetMachine.h"
19 using namespace llvm;
21 namespace {
22 struct XCoreFTAOElim : public MachineFunctionPass {
23 static char ID;
24 XCoreFTAOElim() : MachineFunctionPass(ID) {}
26 bool runOnMachineFunction(MachineFunction &Fn) override;
27 MachineFunctionProperties getRequiredProperties() const override {
28 return MachineFunctionProperties().set(
29 MachineFunctionProperties::Property::NoVRegs);
32 StringRef getPassName() const override {
33 return "XCore FRAME_TO_ARGS_OFFSET Elimination";
36 char XCoreFTAOElim::ID = 0;
39 /// createXCoreFrameToArgsOffsetEliminationPass - returns an instance of the
40 /// Frame to args offset elimination pass
41 FunctionPass *llvm::createXCoreFrameToArgsOffsetEliminationPass() {
42 return new XCoreFTAOElim();
45 bool XCoreFTAOElim::runOnMachineFunction(MachineFunction &MF) {
46 const XCoreInstrInfo &TII =
47 *static_cast<const XCoreInstrInfo *>(MF.getSubtarget().getInstrInfo());
48 unsigned StackSize = MF.getFrameInfo().getStackSize();
49 for (MachineBasicBlock &MBB : MF) {
50 for (MachineBasicBlock::iterator MBBI = MBB.begin(), EE = MBB.end();
51 MBBI != EE; ++MBBI) {
52 if (MBBI->getOpcode() == XCore::FRAME_TO_ARGS_OFFSET) {
53 MachineInstr &OldInst = *MBBI;
54 Register Reg = OldInst.getOperand(0).getReg();
55 MBBI = TII.loadImmediate(MBB, MBBI, Reg, StackSize);
56 OldInst.eraseFromParent();
60 return true;