blob: 42bd7bc8e14ebc534c7fffc0431f373239d26c8f [file] [log] [blame]
Sanjiv Gupta0e687712008-05-13 09:02:57 +00001//===-- PIC16.h - Top-level interface for PIC16 representation --*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Sanjiv Gupta2d4e7f72008-05-14 06:50:01 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Sanjiv Gupta0e687712008-05-13 09:02:57 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file contains the entry points for global functions defined in
11// the LLVM PIC16 back-end.
12//
13//===----------------------------------------------------------------------===//
14
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000015#ifndef LLVM_TARGET_PIC16_H
16#define LLVM_TARGET_PIC16_H
Sanjiv Gupta0e687712008-05-13 09:02:57 +000017
Bill Wendling98a366d2009-04-29 23:29:43 +000018#include "llvm/Target/TargetMachine.h"
Sanjiv Gupta1b046942009-01-13 19:18:47 +000019#include <iosfwd>
20#include <cassert>
21
Sanjiv Gupta0e687712008-05-13 09:02:57 +000022namespace llvm {
23 class PIC16TargetMachine;
Sanjiv Gupta0e687712008-05-13 09:02:57 +000024 class FunctionPass;
25 class MachineCodeEmitter;
Owen Andersoncb371882008-08-21 00:14:44 +000026 class raw_ostream;
Sanjiv Gupta0e687712008-05-13 09:02:57 +000027
Sanjiv Gupta1b046942009-01-13 19:18:47 +000028namespace PIC16CC {
29 enum CondCodes {
30 EQ,
31 NE,
32 LT,
33 LE,
34 GT,
Sanjiv Gupta08b9b052009-01-21 05:44:05 +000035 GE,
36 ULT,
37 UGT,
38 ULE,
39 UGE
Sanjiv Gupta1b046942009-01-13 19:18:47 +000040 };
41}
42
43 inline static const char *PIC16CondCodeToString(PIC16CC::CondCodes CC) {
44 switch (CC) {
45 default: assert(0 && "Unknown condition code");
46 case PIC16CC::NE: return "ne";
47 case PIC16CC::EQ: return "eq";
48 case PIC16CC::LT: return "lt";
Sanjiv Gupta08b9b052009-01-21 05:44:05 +000049 case PIC16CC::ULT: return "lt";
Sanjiv Gupta1b046942009-01-13 19:18:47 +000050 case PIC16CC::LE: return "le";
51 case PIC16CC::GT: return "gt";
Sanjiv Gupta08b9b052009-01-21 05:44:05 +000052 case PIC16CC::UGT: return "gt";
Sanjiv Gupta1b046942009-01-13 19:18:47 +000053 case PIC16CC::GE: return "ge";
54 }
55 }
56
Sanjiv Gupta08b9b052009-01-21 05:44:05 +000057 inline static bool isSignedComparison(PIC16CC::CondCodes CC) {
58 switch (CC) {
59 default: assert(0 && "Unknown condition code");
60 case PIC16CC::NE:
61 case PIC16CC::EQ:
62 case PIC16CC::LT:
63 case PIC16CC::LE:
64 case PIC16CC::GE:
65 case PIC16CC::GT:
66 return true;
67 case PIC16CC::ULT:
68 case PIC16CC::UGT:
69 case PIC16CC::ULE:
70 case PIC16CC::UGE:
71 return false; // condition codes for unsigned comparison.
72 }
73 }
74
Sanjiv Gupta1b046942009-01-13 19:18:47 +000075
Sanjiv Gupta0e687712008-05-13 09:02:57 +000076 FunctionPass *createPIC16ISelDag(PIC16TargetMachine &TM);
Owen Andersoncb371882008-08-21 00:14:44 +000077 FunctionPass *createPIC16CodePrinterPass(raw_ostream &OS,
Bill Wendling57f0db82009-02-24 08:30:20 +000078 PIC16TargetMachine &TM,
Bill Wendling98a366d2009-04-29 23:29:43 +000079 CodeGenOpt::Level OptLevel,
80 bool Verbose);
Sanjiv Gupta0e687712008-05-13 09:02:57 +000081} // end namespace llvm;
82
83// Defines symbolic names for PIC16 registers. This defines a mapping from
84// register name to register number.
85#include "PIC16GenRegisterNames.inc"
86
87// Defines symbolic names for the PIC16 instructions.
88#include "PIC16GenInstrNames.inc"
89
90#endif