1//===-- IntrinsicLowering.h - Intrinsic Function Lowering -------*- 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//
10// This file defines the IntrinsicLowering interface.  This interface allows
11// addition of domain-specific or front-end specific intrinsics to LLVM without
12// having to modify all of the C backend or interpreter.
13//
14//===----------------------------------------------------------------------===//
15
16#ifndef LLVM_CODEGEN_INTRINSICLOWERING_H
17#define LLVM_CODEGEN_INTRINSICLOWERING_H
18
19#include "llvm/IR/Intrinsics.h"
20
21namespace llvm {
22class CallInst;
23class Module;
24class DataLayout;
25
26class IntrinsicLowering {
27  const DataLayout &DL;
28
29  bool Warned;
30
31public:
32  explicit IntrinsicLowering(const DataLayout &DL) : DL(DL), Warned(false) {}
33
34  /// AddPrototypes - This method, if called, causes all of the prototypes
35  /// that might be needed by an intrinsic lowering implementation to be
36  /// inserted into the module specified.
37  void AddPrototypes(Module &M);
38
39  /// LowerIntrinsicCall - This method replaces a call with the LLVM function
40  /// which should be used to implement the specified intrinsic function call.
41  /// If an intrinsic function must be implemented by the code generator
42  /// (such as va_start), this function should print a message and abort.
43  ///
44  /// Otherwise, if an intrinsic function call can be lowered, the code to
45  /// implement it (often a call to a non-intrinsic function) is inserted
46  /// _after_ the call instruction and the call is deleted.  The caller must
47  /// be capable of handling this kind of change.
48  ///
49  void LowerIntrinsicCall(CallInst *CI);
50
51  /// LowerToByteSwap - Replace a call instruction into a call to bswap
52  /// intrinsic. Return false if it has determined the call is not a
53  /// simple integer bswap.
54  static bool LowerToByteSwap(CallInst *CI);
55};
56}
57
58#endif
59