1894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//===-- ARMSelectionDAGInfo.h - ARM SelectionDAG Info -----------*- C++ -*-===//
2894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//
3894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//                     The LLVM Compiler Infrastructure
4894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//
5894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// This file is distributed under the University of Illinois Open Source
6894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// License. See LICENSE.TXT for details.
7894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//
8894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//===----------------------------------------------------------------------===//
9894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//
10894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// This file defines the ARM subclass for TargetSelectionDAGInfo.
11894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//
12894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//===----------------------------------------------------------------------===//
13894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
14894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#ifndef ARMSELECTIONDAGINFO_H
15894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define ARMSELECTIONDAGINFO_H
16894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
1719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman#include "MCTargetDesc/ARMAddressingModes.h"
18894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/Target/TargetSelectionDAGInfo.h"
19894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
20894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumannamespace llvm {
21894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
2219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Baumannamespace ARM_AM {
2319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  static inline ShiftOpc getShiftOpcForNode(unsigned Opcode) {
2419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    switch (Opcode) {
2519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    default:          return ARM_AM::no_shift;
2619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    case ISD::SHL:    return ARM_AM::lsl;
2719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    case ISD::SRL:    return ARM_AM::lsr;
2819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    case ISD::SRA:    return ARM_AM::asr;
2919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    case ISD::ROTR:   return ARM_AM::ror;
3019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    //case ISD::ROTL:  // Only if imm -> turn into ROTR.
3119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    // Can't handle RRX here, because it would require folding a flag into
3219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    // the addressing mode.  :(  This causes us to miss certain things.
3319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    //case ARMISD::RRX: return ARM_AM::rrx;
3419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    }
3519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  }
3619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman}  // end namespace ARM_AM
3719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
38894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanclass ARMSelectionDAGInfo : public TargetSelectionDAGInfo {
39894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// Subtarget - Keep a pointer to the ARMSubtarget around so that we can
40894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// make the right decision when generating code for different targets.
41894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  const ARMSubtarget *Subtarget;
42894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
43894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanpublic:
44894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  explicit ARMSelectionDAGInfo(const TargetMachine &TM);
45894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ~ARMSelectionDAGInfo();
46894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
47894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  virtual
48894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  SDValue EmitTargetCodeForMemcpy(SelectionDAG &DAG, DebugLoc dl,
49894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                                  SDValue Chain,
50894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                                  SDValue Dst, SDValue Src,
51894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                                  SDValue Size, unsigned Align,
52894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                                  bool isVolatile, bool AlwaysInline,
5319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman                                  MachinePointerInfo DstPtrInfo,
5419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman                                  MachinePointerInfo SrcPtrInfo) const;
5519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
5619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  // Adjust parameters for memset, see RTABI section 4.3.4
5719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  virtual
5819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  SDValue EmitTargetCodeForMemset(SelectionDAG &DAG, DebugLoc dl,
5919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman                                  SDValue Chain,
6019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman                                  SDValue Op1, SDValue Op2,
6119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman                                  SDValue Op3, unsigned Align,
6219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman                                  bool isVolatile,
6319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman                                  MachinePointerInfo DstPtrInfo) const;
64894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman};
65894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
66894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman}
67894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
68894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#endif
69