| 1 | //===------ AVR.cpp - Emit LLVM Code for AVR builtins ---------------------===// |
|---|---|
| 2 | // |
| 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 |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This contains code to emit Builtin calls as LLVM code. |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
| 13 | #include "CGBuiltin.h" |
| 14 | #include "clang/Basic/TargetBuiltins.h" |
| 15 | #include "llvm/IR/InlineAsm.h" |
| 16 | #include "llvm/IR/IntrinsicsAVR.h" |
| 17 | |
| 18 | using namespace clang; |
| 19 | using namespace CodeGen; |
| 20 | using namespace llvm; |
| 21 | |
| 22 | Value *CodeGenFunction::EmitAVRBuiltinExpr(unsigned BuiltinID, |
| 23 | const CallExpr *E) { |
| 24 | switch (BuiltinID) { |
| 25 | default: |
| 26 | return nullptr; |
| 27 | case AVR::BI__builtin_avr_nop: |
| 28 | return Builder.CreateCall(Callee: CGM.getIntrinsic(IID: Intrinsic::avr_nop)); |
| 29 | case AVR::BI__builtin_avr_sei: |
| 30 | return Builder.CreateCall(Callee: CGM.getIntrinsic(IID: Intrinsic::avr_sei)); |
| 31 | case AVR::BI__builtin_avr_cli: |
| 32 | return Builder.CreateCall(Callee: CGM.getIntrinsic(IID: Intrinsic::avr_cli)); |
| 33 | case AVR::BI__builtin_avr_sleep: |
| 34 | return Builder.CreateCall(Callee: CGM.getIntrinsic(IID: Intrinsic::avr_sleep)); |
| 35 | case AVR::BI__builtin_avr_wdr: |
| 36 | return Builder.CreateCall(Callee: CGM.getIntrinsic(IID: Intrinsic::avr_wdr)); |
| 37 | case AVR::BI__builtin_avr_swap: { |
| 38 | Value *Arg0 = EmitScalarExpr(E: E->getArg(Arg: 0)); |
| 39 | return Builder.CreateCall(Callee: CGM.getIntrinsic(IID: Intrinsic::avr_swap), Args: Arg0); |
| 40 | } |
| 41 | } |
| 42 | } |
| 43 |