| Diana Picus | 2227493 | 2016-11-11 08:27:37 +0000 | [diff] [blame] | 1 | //===- ARMLegalizerInfo ------------------------------------------*- C++ -*-==// |
| 2 | // |
| Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 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 |
| Diana Picus | 2227493 | 2016-11-11 08:27:37 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | /// \file |
| 9 | /// This file declares the targeting of the Machinelegalizer class for ARM. |
| 10 | /// \todo This should be generated by TableGen. |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
| 13 | #ifndef LLVM_LIB_TARGET_ARM_ARMMACHINELEGALIZER_H |
| 14 | #define LLVM_LIB_TARGET_ARM_ARMMACHINELEGALIZER_H |
| 15 | |
| Diana Picus | d0104ea | 2017-07-06 09:09:33 +0000 | [diff] [blame] | 16 | #include "llvm/ADT/IndexedMap.h" |
| Aditya Nandakumar | f75d4f3 | 2018-12-05 20:14:52 +0000 | [diff] [blame] | 17 | #include "llvm/CodeGen/GlobalISel/GISelChangeObserver.h" |
| Diana Picus | 2227493 | 2016-11-11 08:27:37 +0000 | [diff] [blame] | 18 | #include "llvm/CodeGen/GlobalISel/LegalizerInfo.h" |
| Diana Picus | d0104ea | 2017-07-06 09:09:33 +0000 | [diff] [blame] | 19 | #include "llvm/CodeGen/RuntimeLibcalls.h" |
| 20 | #include "llvm/IR/Instructions.h" |
| Diana Picus | 2227493 | 2016-11-11 08:27:37 +0000 | [diff] [blame] | 21 | |
| 22 | namespace llvm { |
| 23 | |
| Diana Picus | 7cab078 | 2017-02-17 11:25:17 +0000 | [diff] [blame] | 24 | class ARMSubtarget; |
| Diana Picus | 2227493 | 2016-11-11 08:27:37 +0000 | [diff] [blame] | 25 | |
| 26 | /// This class provides the information for the target register banks. |
| 27 | class ARMLegalizerInfo : public LegalizerInfo { |
| 28 | public: |
| Diana Picus | 7cab078 | 2017-02-17 11:25:17 +0000 | [diff] [blame] | 29 | ARMLegalizerInfo(const ARMSubtarget &ST); |
| Diana Picus | f53865d | 2017-04-24 09:12:19 +0000 | [diff] [blame] | 30 | |
| 31 | bool legalizeCustom(MachineInstr &MI, MachineRegisterInfo &MRI, |
| Aditya Nandakumar | f75d4f3 | 2018-12-05 20:14:52 +0000 | [diff] [blame] | 32 | MachineIRBuilder &MIRBuilder, |
| 33 | GISelChangeObserver &Observer) const override; |
| Diana Picus | d0104ea | 2017-07-06 09:09:33 +0000 | [diff] [blame] | 34 | |
| 35 | private: |
| 36 | void setFCmpLibcallsGNU(); |
| 37 | void setFCmpLibcallsAEABI(); |
| 38 | |
| 39 | struct FCmpLibcallInfo { |
| 40 | // Which libcall this is. |
| 41 | RTLIB::Libcall LibcallID; |
| 42 | |
| 43 | // The predicate to be used when comparing the value returned by the |
| 44 | // function with a relevant constant (currently hard-coded to zero). This is |
| 45 | // necessary because often the libcall will return e.g. a value greater than |
| 46 | // 0 to represent 'true' and anything negative to represent 'false', or |
| 47 | // maybe 0 to represent 'true' and non-zero for 'false'. If no comparison is |
| 48 | // needed, this should be CmpInst::BAD_ICMP_PREDICATE. |
| 49 | CmpInst::Predicate Predicate; |
| 50 | }; |
| 51 | using FCmpLibcallsList = SmallVector<FCmpLibcallInfo, 2>; |
| 52 | |
| 53 | // Map from each FCmp predicate to the corresponding libcall infos. A FCmp |
| 54 | // instruction may be lowered to one or two libcalls, which is why we need a |
| 55 | // list. If two libcalls are needed, their results will be OR'ed. |
| 56 | using FCmpLibcallsMapTy = IndexedMap<FCmpLibcallsList>; |
| 57 | |
| 58 | FCmpLibcallsMapTy FCmp32Libcalls; |
| Diana Picus | b57bba8 | 2017-07-11 08:50:01 +0000 | [diff] [blame] | 59 | FCmpLibcallsMapTy FCmp64Libcalls; |
| Diana Picus | d0104ea | 2017-07-06 09:09:33 +0000 | [diff] [blame] | 60 | |
| Diana Picus | b57bba8 | 2017-07-11 08:50:01 +0000 | [diff] [blame] | 61 | // Get the libcall(s) corresponding to \p Predicate for operands of \p Size |
| 62 | // bits. |
| 63 | FCmpLibcallsList getFCmpLibcalls(CmpInst::Predicate, unsigned Size) const; |
| Diana Picus | 2227493 | 2016-11-11 08:27:37 +0000 | [diff] [blame] | 64 | }; |
| 65 | } // End llvm namespace. |
| 66 | #endif |