blob: 8593f54f396128f83d28925199de501aaa7bd03f [file] [log] [blame]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001//===-- IntrinsicLowering.h - Intrinsic Function Lowering -------*- C++ -*-===//
2//
Andrew Walbran16937d02019-10-22 13:54:20 +01003// 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
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006//
7//===----------------------------------------------------------------------===//
8//
9// This file defines the IntrinsicLowering interface. This interface allows
10// addition of domain-specific or front-end specific intrinsics to LLVM without
11// having to modify all of the C backend or interpreter.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_CODEGEN_INTRINSICLOWERING_H
16#define LLVM_CODEGEN_INTRINSICLOWERING_H
17
18#include "llvm/IR/Intrinsics.h"
19
20namespace llvm {
21class CallInst;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010022class DataLayout;
23
24class IntrinsicLowering {
25 const DataLayout &DL;
26
27 bool Warned;
28
29public:
30 explicit IntrinsicLowering(const DataLayout &DL) : DL(DL), Warned(false) {}
31
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010032 /// Replace a call to the specified intrinsic function.
33 /// If an intrinsic function must be implemented by the code generator
34 /// (such as va_start), this function should print a message and abort.
35 ///
36 /// Otherwise, if an intrinsic function call can be lowered, the code to
37 /// implement it (often a call to a non-intrinsic function) is inserted
38 /// _after_ the call instruction and the call is deleted. The caller must
39 /// be capable of handling this kind of change.
40 void LowerIntrinsicCall(CallInst *CI);
41
42 /// Try to replace a call instruction with a call to a bswap intrinsic. Return
43 /// false if the call is not a simple integer bswap.
44 static bool LowerToByteSwap(CallInst *CI);
45};
46}
47
48#endif