Petar Jovanovic | fac93e2 | 2018-02-23 11:06:40 +0000 | [diff] [blame] | 1 | //===- MipsLegalizerInfo.cpp ------------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | /// \file |
| 10 | /// This file implements the targeting of the Machinelegalizer class for Mips. |
| 11 | /// \todo This should be generated by TableGen. |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "MipsLegalizerInfo.h" |
Roman Tereshin | f34d7ec | 2018-05-31 16:16:49 +0000 | [diff] [blame] | 15 | #include "MipsTargetMachine.h" |
Petar Jovanovic | aa97890 | 2018-10-08 23:59:37 +0000 | [diff] [blame] | 16 | #include "llvm/CodeGen/GlobalISel/LegalizerHelper.h" |
Petar Jovanovic | fac93e2 | 2018-02-23 11:06:40 +0000 | [diff] [blame] | 17 | |
| 18 | using namespace llvm; |
| 19 | |
| 20 | MipsLegalizerInfo::MipsLegalizerInfo(const MipsSubtarget &ST) { |
Petar Jovanovic | 366857a | 2018-04-11 15:12:32 +0000 | [diff] [blame] | 21 | using namespace TargetOpcode; |
| 22 | |
Petar Avramovic | b8276f2 | 2018-12-17 12:31:07 +0000 | [diff] [blame] | 23 | const LLT s1 = LLT::scalar(1); |
Petar Jovanovic | 366857a | 2018-04-11 15:12:32 +0000 | [diff] [blame] | 24 | const LLT s32 = LLT::scalar(32); |
Petar Jovanovic | 021e4c8 | 2018-07-16 13:29:32 +0000 | [diff] [blame] | 25 | const LLT p0 = LLT::pointer(0, 32); |
Petar Jovanovic | 366857a | 2018-04-11 15:12:32 +0000 | [diff] [blame] | 26 | |
Petar Jovanovic | 1fa5051 | 2018-08-26 07:25:33 +0000 | [diff] [blame] | 27 | getActionDefinitionsBuilder(G_ADD) |
| 28 | .legalFor({s32}) |
Petar Avramovic | b8276f2 | 2018-12-17 12:31:07 +0000 | [diff] [blame] | 29 | .clampScalar(0, s32, s32); |
| 30 | |
| 31 | getActionDefinitionsBuilder(G_UADDE) |
| 32 | .lowerFor({{s32, s1}}); |
Petar Jovanovic | 366857a | 2018-04-11 15:12:32 +0000 | [diff] [blame] | 33 | |
Petar Jovanovic | 021e4c8 | 2018-07-16 13:29:32 +0000 | [diff] [blame] | 34 | getActionDefinitionsBuilder({G_LOAD, G_STORE}) |
Petar Jovanovic | 58c0210 | 2018-07-25 12:35:01 +0000 | [diff] [blame] | 35 | .legalForCartesianProduct({p0, s32}, {p0}); |
Petar Jovanovic | 021e4c8 | 2018-07-16 13:29:32 +0000 | [diff] [blame] | 36 | |
Petar Jovanovic | 3b953c3 | 2018-08-21 08:15:56 +0000 | [diff] [blame] | 37 | getActionDefinitionsBuilder({G_AND, G_OR, G_XOR, G_SHL, G_ASHR, G_LSHR}) |
| 38 | .legalFor({s32}); |
| 39 | |
Petar Jovanovic | ce4dd0a | 2018-09-10 15:56:52 +0000 | [diff] [blame] | 40 | getActionDefinitionsBuilder(G_ICMP) |
| 41 | .legalFor({{s32, s32}}) |
| 42 | .minScalar(0, s32); |
| 43 | |
Petar Jovanovic | 021e4c8 | 2018-07-16 13:29:32 +0000 | [diff] [blame] | 44 | getActionDefinitionsBuilder(G_CONSTANT) |
Petar Jovanovic | 8a08412 | 2018-10-17 10:30:03 +0000 | [diff] [blame] | 45 | .legalFor({s32}) |
Petar Avramovic | 2cefaa2 | 2018-11-09 14:21:16 +0000 | [diff] [blame] | 46 | .clampScalar(0, s32, s32); |
Petar Jovanovic | 021e4c8 | 2018-07-16 13:29:32 +0000 | [diff] [blame] | 47 | |
| 48 | getActionDefinitionsBuilder(G_GEP) |
| 49 | .legalFor({{p0, s32}}); |
| 50 | |
| 51 | getActionDefinitionsBuilder(G_FRAME_INDEX) |
| 52 | .legalFor({p0}); |
| 53 | |
Petar Jovanovic | 64c10ba | 2018-08-01 09:03:23 +0000 | [diff] [blame] | 54 | getActionDefinitionsBuilder(G_GLOBAL_VALUE) |
| 55 | .legalFor({p0}); |
| 56 | |
Petar Jovanovic | fac93e2 | 2018-02-23 11:06:40 +0000 | [diff] [blame] | 57 | computeTables(); |
Roman Tereshin | f34d7ec | 2018-05-31 16:16:49 +0000 | [diff] [blame] | 58 | verify(*ST.getInstrInfo()); |
Petar Jovanovic | fac93e2 | 2018-02-23 11:06:40 +0000 | [diff] [blame] | 59 | } |
Petar Jovanovic | aa97890 | 2018-10-08 23:59:37 +0000 | [diff] [blame] | 60 | |
| 61 | bool MipsLegalizerInfo::legalizeCustom(MachineInstr &MI, |
| 62 | MachineRegisterInfo &MRI, |
Aditya Nandakumar | f75d4f3 | 2018-12-05 20:14:52 +0000 | [diff] [blame] | 63 | MachineIRBuilder &MIRBuilder, |
| 64 | GISelChangeObserver &Observer) const { |
Petar Jovanovic | aa97890 | 2018-10-08 23:59:37 +0000 | [diff] [blame] | 65 | |
| 66 | using namespace TargetOpcode; |
| 67 | |
| 68 | MIRBuilder.setInstr(MI); |
| 69 | |
Petar Avramovic | f9c9bc0 | 2018-12-17 15:12:53 +0000 | [diff] [blame^] | 70 | return false; |
Petar Jovanovic | aa97890 | 2018-10-08 23:59:37 +0000 | [diff] [blame] | 71 | } |