blob: 29f907923083f9d93d4d771b5d2be58563309b82 [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
Torok Edwinc25e7582009-07-11 20:10:48 +000018#include "llvm/Support/ErrorHandling.h"
Bill Wendling98a366d2009-04-29 23:29:43 +000019#include "llvm/Target/TargetMachine.h"
Sanjiv Gupta1b046942009-01-13 19:18:47 +000020#include <iosfwd>
21#include <cassert>
Sanjiv Gupta211f3622009-05-10 05:23:47 +000022#include <sstream>
Nick Lewycky4a228862009-05-08 06:22:25 +000023#include <cstring>
Sanjiv Guptad8d27f42009-05-06 08:02:01 +000024#include <string>
Sanjiv Guptaeb01aba2009-08-20 19:28:24 +000025#include "PIC16PAN.h"
Sanjiv Gupta1b046942009-01-13 19:18:47 +000026
Sanjiv Gupta0e687712008-05-13 09:02:57 +000027namespace llvm {
28 class PIC16TargetMachine;
Sanjiv Gupta0e687712008-05-13 09:02:57 +000029 class FunctionPass;
30 class MachineCodeEmitter;
David Greene71847812009-07-14 20:18:05 +000031 class formatted_raw_ostream;
Sanjiv Gupta0e687712008-05-13 09:02:57 +000032
Sanjiv Gupta1b046942009-01-13 19:18:47 +000033namespace PIC16CC {
34 enum CondCodes {
35 EQ,
36 NE,
37 LT,
38 LE,
39 GT,
Sanjiv Gupta08b9b052009-01-21 05:44:05 +000040 GE,
41 ULT,
42 UGT,
43 ULE,
44 UGE
Sanjiv Gupta1b046942009-01-13 19:18:47 +000045 };
46}
Sanjiv Gupta211f3622009-05-10 05:23:47 +000047 // External symbol names require memory to live till the program end.
48 // So we have to allocate it and keep.
49 inline static const char *createESName (const std::string &name) {
50 char *tmpName = new char[name.size() + 1];
51 strcpy (tmpName, name.c_str());
52 return tmpName;
53 }
Sanjiv Gupta573eb5e2009-05-08 04:50:14 +000054
Sanjiv Guptad8d27f42009-05-06 08:02:01 +000055
Sanjiv Gupta1b046942009-01-13 19:18:47 +000056
57 inline static const char *PIC16CondCodeToString(PIC16CC::CondCodes CC) {
58 switch (CC) {
Torok Edwinc23197a2009-07-14 16:55:14 +000059 default: llvm_unreachable("Unknown condition code");
Sanjiv Gupta1b046942009-01-13 19:18:47 +000060 case PIC16CC::NE: return "ne";
61 case PIC16CC::EQ: return "eq";
62 case PIC16CC::LT: return "lt";
Sanjiv Gupta08b9b052009-01-21 05:44:05 +000063 case PIC16CC::ULT: return "lt";
Sanjiv Gupta1b046942009-01-13 19:18:47 +000064 case PIC16CC::LE: return "le";
Sanjiv Gupta703e2352009-06-03 13:36:44 +000065 case PIC16CC::ULE: return "le";
Sanjiv Gupta1b046942009-01-13 19:18:47 +000066 case PIC16CC::GT: return "gt";
Sanjiv Gupta08b9b052009-01-21 05:44:05 +000067 case PIC16CC::UGT: return "gt";
Sanjiv Gupta1b046942009-01-13 19:18:47 +000068 case PIC16CC::GE: return "ge";
Sanjiv Gupta703e2352009-06-03 13:36:44 +000069 case PIC16CC::UGE: return "ge";
Sanjiv Gupta1b046942009-01-13 19:18:47 +000070 }
71 }
72
Sanjiv Gupta08b9b052009-01-21 05:44:05 +000073 inline static bool isSignedComparison(PIC16CC::CondCodes CC) {
74 switch (CC) {
Torok Edwinc23197a2009-07-14 16:55:14 +000075 default: llvm_unreachable("Unknown condition code");
Sanjiv Gupta08b9b052009-01-21 05:44:05 +000076 case PIC16CC::NE:
77 case PIC16CC::EQ:
78 case PIC16CC::LT:
79 case PIC16CC::LE:
80 case PIC16CC::GE:
81 case PIC16CC::GT:
82 return true;
83 case PIC16CC::ULT:
84 case PIC16CC::UGT:
85 case PIC16CC::ULE:
86 case PIC16CC::UGE:
87 return false; // condition codes for unsigned comparison.
88 }
89 }
90
Sanjiv Gupta1b046942009-01-13 19:18:47 +000091
Sanjiv Guptad8d27f42009-05-06 08:02:01 +000092
Sanjiv Gupta0e687712008-05-13 09:02:57 +000093 FunctionPass *createPIC16ISelDag(PIC16TargetMachine &TM);
Daniel Dunbar0c795d62009-07-25 06:49:55 +000094 // Banksel optimizer pass.
Sanjiv Guptad8d27f42009-05-06 08:02:01 +000095 FunctionPass *createPIC16MemSelOptimizerPass();
Daniel Dunbar4cb1e132009-07-18 23:03:22 +000096
97 extern Target ThePIC16Target;
98 extern Target TheCooperTarget;
99
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000100} // end namespace llvm;
101
102// Defines symbolic names for PIC16 registers. This defines a mapping from
103// register name to register number.
104#include "PIC16GenRegisterNames.inc"
105
106// Defines symbolic names for the PIC16 instructions.
107#include "PIC16GenInstrNames.inc"
108
109#endif