blob: a6712d5a0e7242b91f5e248860e31ee257c3ac21 [file] [log] [blame]
Jia Liub22310f2012-02-18 12:03:15 +00001//===-- Thumb2InstrInfo.h - Thumb-2 Instruction Information -----*- C++ -*-===//
David Goodwinade05a32009-07-02 22:18:33 +00002//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
David Goodwinade05a32009-07-02 22:18:33 +00006//
7//===----------------------------------------------------------------------===//
8//
9// This file contains the Thumb-2 implementation of the TargetInstrInfo class.
10//
11//===----------------------------------------------------------------------===//
12
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000013#ifndef LLVM_LIB_TARGET_ARM_THUMB2INSTRINFO_H
14#define LLVM_LIB_TARGET_ARM_THUMB2INSTRINFO_H
David Goodwinade05a32009-07-02 22:18:33 +000015
Craig Topper07720d82012-03-25 23:49:58 +000016#include "ARMBaseInstrInfo.h"
Eric Christopherae326492015-03-12 22:48:50 +000017#include "ThumbRegisterInfo.h"
David Goodwinade05a32009-07-02 22:18:33 +000018
19namespace llvm {
Evan Cheng2d51c7c2010-06-18 23:09:54 +000020class ARMSubtarget;
21class ScheduleHazardRecognizer;
David Goodwinade05a32009-07-02 22:18:33 +000022
23class Thumb2InstrInfo : public ARMBaseInstrInfo {
Eric Christopherae326492015-03-12 22:48:50 +000024 ThumbRegisterInfo RI;
David Goodwinade05a32009-07-02 22:18:33 +000025public:
26 explicit Thumb2InstrInfo(const ARMSubtarget &STI);
27
Hans Wennborg9b9a5352017-04-21 21:48:41 +000028 /// Return the noop instruction to use for a noop.
29 void getNoop(MCInst &NopInst) const override;
Jim Grosbach617f84dd2012-02-28 23:53:30 +000030
David Goodwinaf7451b2009-07-08 16:09:28 +000031 // Return the non-pre/post incrementing version of 'Opc'. Return 0
32 // if there is not such an opcode.
Craig Topper6bc27bf2014-03-10 02:09:33 +000033 unsigned getUnindexedOpcode(unsigned Opc) const override;
David Goodwinaf7451b2009-07-08 16:09:28 +000034
Evan Cheng2d51c7c2010-06-18 23:09:54 +000035 void ReplaceTailWithBranchTo(MachineBasicBlock::iterator Tail,
Craig Topper6bc27bf2014-03-10 02:09:33 +000036 MachineBasicBlock *NewDest) const override;
Evan Cheng2d51c7c2010-06-18 23:09:54 +000037
Evan Cheng37bb6172010-06-22 01:18:16 +000038 bool isLegalToSplitMBBAt(MachineBasicBlock &MBB,
Craig Topper6bc27bf2014-03-10 02:09:33 +000039 MachineBasicBlock::iterator MBBI) const override;
Evan Cheng37bb6172010-06-22 01:18:16 +000040
Benjamin Kramerbdc49562016-06-12 15:39:02 +000041 void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
42 const DebugLoc &DL, unsigned DestReg, unsigned SrcReg,
Craig Topper6bc27bf2014-03-10 02:09:33 +000043 bool KillSrc) const override;
Anton Korobeynikovc5df7e22009-07-16 23:26:06 +000044
Evan Chengc47e1092009-07-27 03:14:20 +000045 void storeRegToStackSlot(MachineBasicBlock &MBB,
46 MachineBasicBlock::iterator MBBI,
47 unsigned SrcReg, bool isKill, int FrameIndex,
Evan Chengefb126a2010-05-06 19:06:44 +000048 const TargetRegisterClass *RC,
Craig Topper6bc27bf2014-03-10 02:09:33 +000049 const TargetRegisterInfo *TRI) const override;
Evan Chengc47e1092009-07-27 03:14:20 +000050
51 void loadRegFromStackSlot(MachineBasicBlock &MBB,
52 MachineBasicBlock::iterator MBBI,
53 unsigned DestReg, int FrameIndex,
Evan Chengefb126a2010-05-06 19:06:44 +000054 const TargetRegisterClass *RC,
Craig Topper6bc27bf2014-03-10 02:09:33 +000055 const TargetRegisterInfo *TRI) const override;
Evan Chengc47e1092009-07-27 03:14:20 +000056
David Goodwinade05a32009-07-02 22:18:33 +000057 /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As
58 /// such, whenever a client has an instance of instruction info, it should
59 /// always be able to get register info as well (through this method).
60 ///
Eric Christopherae326492015-03-12 22:48:50 +000061 const ThumbRegisterInfo &getRegisterInfo() const override { return RI; }
Akira Hatanakae5b6e0d2014-07-25 19:31:34 +000062
63private:
Rafael Espindola82f46312016-06-28 15:18:26 +000064 void expandLoadStackGuard(MachineBasicBlock::iterator MI) const override;
David Goodwinade05a32009-07-02 22:18:33 +000065};
Evan Cheng37bb6172010-06-22 01:18:16 +000066
67/// getITInstrPredicate - Valid only in Thumb2 mode. This function is identical
68/// to llvm::getInstrPredicate except it returns AL for conditional branch
69/// instructions which are "predicated", but are not in IT blocks.
Duncan P. N. Exon Smith6307eb52016-02-23 02:46:52 +000070ARMCC::CondCodes getITInstrPredicate(const MachineInstr &MI, unsigned &PredReg);
Sjoerd Meijer3058a622019-06-14 11:46:05 +000071
72// getVPTInstrPredicate: VPT analogue of that, plus a helper function
73// corresponding to MachineInstr::findFirstPredOperandIdx.
74int findFirstVPTPredOperandIdx(const MachineInstr &MI);
75ARMVCC::VPTCodes getVPTInstrPredicate(const MachineInstr &MI,
76 unsigned &PredReg);
Alexander Kornienkof00654e2015-06-23 09:49:53 +000077}
David Goodwinade05a32009-07-02 22:18:33 +000078
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000079#endif