blob: c2aabf7116e4a45749478a0d703b9cacf86e53f9 [file] [log] [blame]
Chris Lattner9e493cf2006-03-03 02:32:46 +00001//===- IntrinsicEmitter.cpp - Generate intrinsic information --------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner30609102007-12-29 20:37:13 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Chris Lattner9e493cf2006-03-03 02:32:46 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This tablegen backend emits information about intrinsic functions.
11//
12//===----------------------------------------------------------------------===//
13
Chandler Carruth69940402007-08-04 01:51:18 +000014#include "CodeGenTarget.h"
Chris Lattner9e493cf2006-03-03 02:32:46 +000015#include "IntrinsicEmitter.h"
16#include "Record.h"
Chris Lattner298b1762010-09-06 03:14:45 +000017#include "StringMatcher.h"
Chris Lattner18faf5d2006-03-13 22:38:57 +000018#include "llvm/ADT/StringExtras.h"
Jeff Cohen71c3bc32006-03-15 02:51:05 +000019#include <algorithm>
Chris Lattner9e493cf2006-03-03 02:32:46 +000020using namespace llvm;
21
22//===----------------------------------------------------------------------===//
Chris Lattner9e493cf2006-03-03 02:32:46 +000023// IntrinsicEmitter Implementation
24//===----------------------------------------------------------------------===//
25
Daniel Dunbar1a551802009-07-03 00:10:29 +000026void IntrinsicEmitter::run(raw_ostream &OS) {
Chris Lattner9e493cf2006-03-03 02:32:46 +000027 EmitSourceFileHeader("Intrinsic Function Source Fragment", OS);
28
Dale Johannesen49de9822009-02-05 01:49:45 +000029 std::vector<CodeGenIntrinsic> Ints = LoadIntrinsics(Records, TargetOnly);
30
31 if (TargetOnly && !Ints.empty())
32 TargetPrefix = Ints[0].TargetPrefix;
Chris Lattner9e493cf2006-03-03 02:32:46 +000033
Douglas Gregor7d9663c2010-05-11 06:17:44 +000034 EmitPrefix(OS);
35
Chris Lattner9e493cf2006-03-03 02:32:46 +000036 // Emit the enum information.
37 EmitEnumInfo(Ints, OS);
Chris Lattnerfda6aff2006-03-15 01:55:21 +000038
39 // Emit the intrinsic ID -> name table.
40 EmitIntrinsicToNameTable(Ints, OS);
Mon P Wang0d52ff12009-02-24 23:17:49 +000041
42 // Emit the intrinsic ID -> overload table.
43 EmitIntrinsicToOverloadTable(Ints, OS);
44
Chris Lattner9b843b22006-03-09 20:34:19 +000045 // Emit the function name recognizer.
46 EmitFnNameRecognizer(Ints, OS);
Chris Lattnerfda6aff2006-03-15 01:55:21 +000047
Chris Lattnerf97a00e2006-03-09 22:05:04 +000048 // Emit the intrinsic verifier.
49 EmitVerifier(Ints, OS);
Chris Lattner6448ee42006-03-09 22:30:49 +000050
Jim Laskey95af5922007-02-07 20:38:26 +000051 // Emit the intrinsic declaration generator.
52 EmitGenerator(Ints, OS);
53
Duncan Sandsa3355ff2007-12-03 20:06:50 +000054 // Emit the intrinsic parameter attributes.
55 EmitAttributes(Ints, OS);
Chris Lattner022f64f2006-03-13 23:08:44 +000056
Duncan Sandsd869b382009-02-14 10:56:35 +000057 // Emit intrinsic alias analysis mod/ref behavior.
58 EmitModRefBehavior(Ints, OS);
59
Chris Lattner022f64f2006-03-13 23:08:44 +000060 // Emit a list of intrinsics with corresponding GCC builtins.
61 EmitGCCBuiltinList(Ints, OS);
Chris Lattner3f8b8912006-03-15 01:33:26 +000062
63 // Emit code to translate GCC builtins into LLVM intrinsics.
64 EmitIntrinsicToGCCBuiltinMap(Ints, OS);
Douglas Gregor7d9663c2010-05-11 06:17:44 +000065
66 EmitSuffix(OS);
67}
68
69void IntrinsicEmitter::EmitPrefix(raw_ostream &OS) {
70 OS << "// VisualStudio defines setjmp as _setjmp\n"
71 "#if defined(_MSC_VER) && defined(setjmp)\n"
Michael J. Spencer08047f62010-09-14 04:27:38 +000072 "# pragma push_macro(\"setjmp\")\n"
73 "# undef setjmp\n"
Douglas Gregor7d9663c2010-05-11 06:17:44 +000074 "#endif\n\n";
75}
76
77void IntrinsicEmitter::EmitSuffix(raw_ostream &OS) {
Michael J. Spencer08047f62010-09-14 04:27:38 +000078 OS << "#if defined(_MSC_VER)\n"
Douglas Gregor7d9663c2010-05-11 06:17:44 +000079 "// let's return it to _setjmp state\n"
Michael J. Spencer08047f62010-09-14 04:27:38 +000080 "# pragma pop_macro(\"setjmp\")\n"
Douglas Gregor7d9663c2010-05-11 06:17:44 +000081 "#endif\n\n";
Chris Lattner9e493cf2006-03-03 02:32:46 +000082}
83
84void IntrinsicEmitter::EmitEnumInfo(const std::vector<CodeGenIntrinsic> &Ints,
Daniel Dunbar1a551802009-07-03 00:10:29 +000085 raw_ostream &OS) {
Chris Lattner9b843b22006-03-09 20:34:19 +000086 OS << "// Enum values for Intrinsics.h\n";
Chris Lattner9e493cf2006-03-03 02:32:46 +000087 OS << "#ifdef GET_INTRINSIC_ENUM_VALUES\n";
88 for (unsigned i = 0, e = Ints.size(); i != e; ++i) {
89 OS << " " << Ints[i].EnumName;
90 OS << ((i != e-1) ? ", " : " ");
91 OS << std::string(40-Ints[i].EnumName.size(), ' ')
92 << "// " << Ints[i].Name << "\n";
93 }
94 OS << "#endif\n\n";
95}
Chris Lattner9b843b22006-03-09 20:34:19 +000096
97void IntrinsicEmitter::
98EmitFnNameRecognizer(const std::vector<CodeGenIntrinsic> &Ints,
Daniel Dunbar1a551802009-07-03 00:10:29 +000099 raw_ostream &OS) {
Chris Lattnercc67c752010-09-06 03:58:45 +0000100 // Build a 'first character of function name' -> intrinsic # mapping.
101 std::map<char, std::vector<unsigned> > IntMapping;
Chris Lattner9b843b22006-03-09 20:34:19 +0000102 for (unsigned i = 0, e = Ints.size(); i != e; ++i)
Chris Lattnercc67c752010-09-06 03:58:45 +0000103 IntMapping[Ints[i].Name[5]].push_back(i);
104
Chris Lattner9b843b22006-03-09 20:34:19 +0000105 OS << "// Function name -> enum value recognizer code.\n";
106 OS << "#ifdef GET_FUNCTION_RECOGNIZER\n";
Chris Lattnercc67c752010-09-06 03:58:45 +0000107 OS << " StringRef NameR(Name+6, Len-6); // Skip over 'llvm.'\n";
108 OS << " switch (Name[5]) { // Dispatch on first letter.\n";
109 OS << " default: break;\n";
110 // Emit the intrinsic matching stuff by first letter.
111 for (std::map<char, std::vector<unsigned> >::iterator I = IntMapping.begin(),
Chris Lattner9b843b22006-03-09 20:34:19 +0000112 E = IntMapping.end(); I != E; ++I) {
Chris Lattnercc67c752010-09-06 03:58:45 +0000113 OS << " case '" << I->first << "':\n";
114 std::vector<unsigned> &IntList = I->second;
115
116 // Emit all the overloaded intrinsics first, build a table of the
117 // non-overloaded ones.
118 std::vector<StringMatcher::StringPair> MatchTable;
119
120 for (unsigned i = 0, e = IntList.size(); i != e; ++i) {
121 unsigned IntNo = IntList[i];
122 std::string Result = "return " + TargetPrefix + "Intrinsic::" +
123 Ints[IntNo].EnumName + ";";
124
125 if (!Ints[IntNo].isOverloaded) {
126 MatchTable.push_back(std::make_pair(Ints[IntNo].Name.substr(6),Result));
127 continue;
128 }
129
130 // For overloaded intrinsics, only the prefix needs to match
131 std::string TheStr = Ints[IntNo].Name.substr(6);
132 TheStr += '.'; // Require "bswap." instead of bswap.
133 OS << " if (NameR.startswith(\"" << TheStr << "\")) "
134 << Result << '\n';
Chris Lattner9b843b22006-03-09 20:34:19 +0000135 }
136
Chris Lattnercc67c752010-09-06 03:58:45 +0000137 // Emit the matcher logic for the fixed length strings.
138 StringMatcher("NameR", MatchTable, OS).Emit(1);
139 OS << " break; // end of '" << I->first << "' case.\n";
Chris Lattner9b843b22006-03-09 20:34:19 +0000140 }
Chris Lattnercc67c752010-09-06 03:58:45 +0000141
Chris Lattner9b843b22006-03-09 20:34:19 +0000142 OS << " }\n";
Chris Lattnerf97a00e2006-03-09 22:05:04 +0000143 OS << "#endif\n\n";
144}
145
Chris Lattnerfda6aff2006-03-15 01:55:21 +0000146void IntrinsicEmitter::
147EmitIntrinsicToNameTable(const std::vector<CodeGenIntrinsic> &Ints,
Daniel Dunbar1a551802009-07-03 00:10:29 +0000148 raw_ostream &OS) {
Chris Lattnerfda6aff2006-03-15 01:55:21 +0000149 OS << "// Intrinsic ID to name table\n";
150 OS << "#ifdef GET_INTRINSIC_NAME_TABLE\n";
151 OS << " // Note that entry #0 is the invalid intrinsic!\n";
Evan Chengf065a6f2006-03-28 22:25:56 +0000152 for (unsigned i = 0, e = Ints.size(); i != e; ++i)
153 OS << " \"" << Ints[i].Name << "\",\n";
Chris Lattnerfda6aff2006-03-15 01:55:21 +0000154 OS << "#endif\n\n";
155}
156
Mon P Wang0d52ff12009-02-24 23:17:49 +0000157void IntrinsicEmitter::
158EmitIntrinsicToOverloadTable(const std::vector<CodeGenIntrinsic> &Ints,
Daniel Dunbar1a551802009-07-03 00:10:29 +0000159 raw_ostream &OS) {
Mon P Wang0d52ff12009-02-24 23:17:49 +0000160 OS << "// Intrinsic ID to overload table\n";
161 OS << "#ifdef GET_INTRINSIC_OVERLOAD_TABLE\n";
162 OS << " // Note that entry #0 is the invalid intrinsic!\n";
163 for (unsigned i = 0, e = Ints.size(); i != e; ++i) {
164 OS << " ";
165 if (Ints[i].isOverloaded)
166 OS << "true";
167 else
168 OS << "false";
169 OS << ",\n";
170 }
171 OS << "#endif\n\n";
172}
173
Owen Anderson825b72b2009-08-11 20:47:22 +0000174static void EmitTypeForValueType(raw_ostream &OS, MVT::SimpleValueType VT) {
Owen Andersone50ed302009-08-10 22:56:29 +0000175 if (EVT(VT).isInteger()) {
176 unsigned BitWidth = EVT(VT).getSizeInBits();
Owen Anderson1d0be152009-08-13 21:58:54 +0000177 OS << "IntegerType::get(Context, " << BitWidth << ")";
Owen Anderson825b72b2009-08-11 20:47:22 +0000178 } else if (VT == MVT::Other) {
179 // MVT::OtherVT is used to mean the empty struct type here.
Owen Andersond7f2a6c2009-08-05 23:16:16 +0000180 OS << "StructType::get(Context)";
Owen Anderson825b72b2009-08-11 20:47:22 +0000181 } else if (VT == MVT::f32) {
Owen Anderson1d0be152009-08-13 21:58:54 +0000182 OS << "Type::getFloatTy(Context)";
Owen Anderson825b72b2009-08-11 20:47:22 +0000183 } else if (VT == MVT::f64) {
Owen Anderson1d0be152009-08-13 21:58:54 +0000184 OS << "Type::getDoubleTy(Context)";
Owen Anderson825b72b2009-08-11 20:47:22 +0000185 } else if (VT == MVT::f80) {
Owen Anderson1d0be152009-08-13 21:58:54 +0000186 OS << "Type::getX86_FP80Ty(Context)";
Owen Anderson825b72b2009-08-11 20:47:22 +0000187 } else if (VT == MVT::f128) {
Owen Anderson1d0be152009-08-13 21:58:54 +0000188 OS << "Type::getFP128Ty(Context)";
Owen Anderson825b72b2009-08-11 20:47:22 +0000189 } else if (VT == MVT::ppcf128) {
Owen Anderson1d0be152009-08-13 21:58:54 +0000190 OS << "Type::getPPC_FP128Ty(Context)";
Owen Anderson825b72b2009-08-11 20:47:22 +0000191 } else if (VT == MVT::isVoid) {
Owen Anderson1d0be152009-08-13 21:58:54 +0000192 OS << "Type::getVoidTy(Context)";
Owen Anderson825b72b2009-08-11 20:47:22 +0000193 } else if (VT == MVT::Metadata) {
Owen Anderson1d0be152009-08-13 21:58:54 +0000194 OS << "Type::getMetadataTy(Context)";
Dale Johannesen8be45252010-09-11 00:16:46 +0000195 } else if (VT == MVT::x86mmx) {
196 OS << "Type::getX86_MMXTy(Context)";
Chandler Carruth69940402007-08-04 01:51:18 +0000197 } else {
198 assert(false && "Unsupported ValueType!");
Chris Lattner18faf5d2006-03-13 22:38:57 +0000199 }
200}
201
Daniel Dunbar1a551802009-07-03 00:10:29 +0000202static void EmitTypeGenerate(raw_ostream &OS, const Record *ArgType,
Bill Wendlingcdcc3e62008-11-13 09:08:33 +0000203 unsigned &ArgNo);
204
Daniel Dunbar1a551802009-07-03 00:10:29 +0000205static void EmitTypeGenerate(raw_ostream &OS,
Bill Wendlingcdcc3e62008-11-13 09:08:33 +0000206 const std::vector<Record*> &ArgTypes,
207 unsigned &ArgNo) {
Chris Lattner93dc92e2010-03-22 20:56:36 +0000208 if (ArgTypes.empty())
209 return EmitTypeForValueType(OS, MVT::isVoid);
210
211 if (ArgTypes.size() == 1)
212 return EmitTypeGenerate(OS, ArgTypes.front(), ArgNo);
Bill Wendlingcdcc3e62008-11-13 09:08:33 +0000213
Owen Andersond7f2a6c2009-08-05 23:16:16 +0000214 OS << "StructType::get(Context, ";
Bill Wendlingcdcc3e62008-11-13 09:08:33 +0000215
216 for (std::vector<Record*>::const_iterator
Bill Wendling20072af2008-11-13 10:18:35 +0000217 I = ArgTypes.begin(), E = ArgTypes.end(); I != E; ++I) {
Bill Wendlingcdcc3e62008-11-13 09:08:33 +0000218 EmitTypeGenerate(OS, *I, ArgNo);
Bill Wendling20072af2008-11-13 10:18:35 +0000219 OS << ", ";
220 }
Bill Wendlingcdcc3e62008-11-13 09:08:33 +0000221
Bill Wendling20072af2008-11-13 10:18:35 +0000222 OS << " NULL)";
Bill Wendlingcdcc3e62008-11-13 09:08:33 +0000223}
224
Daniel Dunbar1a551802009-07-03 00:10:29 +0000225static void EmitTypeGenerate(raw_ostream &OS, const Record *ArgType,
Reid Spencer84c614d2007-05-22 19:30:31 +0000226 unsigned &ArgNo) {
Owen Anderson825b72b2009-08-11 20:47:22 +0000227 MVT::SimpleValueType VT = getValueType(ArgType->getValueAsDef("VT"));
Chandler Carruth69940402007-08-04 01:51:18 +0000228
229 if (ArgType->isSubClassOf("LLVMMatchType")) {
230 unsigned Number = ArgType->getValueAsInt("Number");
231 assert(Number < ArgNo && "Invalid matching number!");
Bob Wilsonbc039792009-01-07 00:09:01 +0000232 if (ArgType->isSubClassOf("LLVMExtendedElementVectorType"))
233 OS << "VectorType::getExtendedElementVectorType"
234 << "(dyn_cast<VectorType>(Tys[" << Number << "]))";
235 else if (ArgType->isSubClassOf("LLVMTruncatedElementVectorType"))
236 OS << "VectorType::getTruncatedElementVectorType"
237 << "(dyn_cast<VectorType>(Tys[" << Number << "]))";
238 else
239 OS << "Tys[" << Number << "]";
Owen Anderson825b72b2009-08-11 20:47:22 +0000240 } else if (VT == MVT::iAny || VT == MVT::fAny || VT == MVT::vAny) {
Reid Spencer84c614d2007-05-22 19:30:31 +0000241 // NOTE: The ArgNo variable here is not the absolute argument number, it is
242 // the index of the "arbitrary" type in the Tys array passed to the
243 // Intrinsic::getDeclaration function. Consequently, we only want to
Chandler Carruth69940402007-08-04 01:51:18 +0000244 // increment it when we actually hit an overloaded type. Getting this wrong
245 // leads to very subtle bugs!
246 OS << "Tys[" << ArgNo++ << "]";
Owen Andersone50ed302009-08-10 22:56:29 +0000247 } else if (EVT(VT).isVector()) {
248 EVT VVT = VT;
Reid Spencer9d6565a2007-02-15 02:26:10 +0000249 OS << "VectorType::get(";
Owen Anderson825b72b2009-08-11 20:47:22 +0000250 EmitTypeForValueType(OS, VVT.getVectorElementType().getSimpleVT().SimpleTy);
Duncan Sands83ec4b62008-06-06 12:08:01 +0000251 OS << ", " << VVT.getVectorNumElements() << ")";
Owen Anderson825b72b2009-08-11 20:47:22 +0000252 } else if (VT == MVT::iPTR) {
Christopher Lamb43ad6b32007-12-17 01:12:55 +0000253 OS << "PointerType::getUnqual(";
Reid Spencerc4de3de2007-04-01 07:20:02 +0000254 EmitTypeGenerate(OS, ArgType->getValueAsDef("ElTy"), ArgNo);
Jim Laskey95af5922007-02-07 20:38:26 +0000255 OS << ")";
Owen Anderson825b72b2009-08-11 20:47:22 +0000256 } else if (VT == MVT::iPTRAny) {
Mon P Wange3b3a722008-07-30 04:36:53 +0000257 // Make sure the user has passed us an argument type to overload. If not,
258 // treat it as an ordinary (not overloaded) intrinsic.
259 OS << "(" << ArgNo << " < numTys) ? Tys[" << ArgNo
260 << "] : PointerType::getUnqual(";
261 EmitTypeGenerate(OS, ArgType->getValueAsDef("ElTy"), ArgNo);
262 OS << ")";
263 ++ArgNo;
Owen Anderson825b72b2009-08-11 20:47:22 +0000264 } else if (VT == MVT::isVoid) {
Chandler Carruth69940402007-08-04 01:51:18 +0000265 if (ArgNo == 0)
Owen Anderson1d0be152009-08-13 21:58:54 +0000266 OS << "Type::getVoidTy(Context)";
Chandler Carruth69940402007-08-04 01:51:18 +0000267 else
Owen Anderson825b72b2009-08-11 20:47:22 +0000268 // MVT::isVoid is used to mean varargs here.
Chandler Carruth69940402007-08-04 01:51:18 +0000269 OS << "...";
Jim Laskey95af5922007-02-07 20:38:26 +0000270 } else {
Chandler Carruth69940402007-08-04 01:51:18 +0000271 EmitTypeForValueType(OS, VT);
Jim Laskey95af5922007-02-07 20:38:26 +0000272 }
273}
274
Jim Grosbachda4231f2009-03-26 16:17:51 +0000275/// RecordListComparator - Provide a deterministic comparator for lists of
Chris Lattnerc4d9b242006-03-31 04:24:58 +0000276/// records.
277namespace {
Bill Wendlingcdcc3e62008-11-13 09:08:33 +0000278 typedef std::pair<std::vector<Record*>, std::vector<Record*> > RecPair;
Chris Lattnerc4d9b242006-03-31 04:24:58 +0000279 struct RecordListComparator {
Bill Wendlingcdcc3e62008-11-13 09:08:33 +0000280 bool operator()(const RecPair &LHS,
281 const RecPair &RHS) const {
Chris Lattnerc4d9b242006-03-31 04:24:58 +0000282 unsigned i = 0;
Bill Wendlingcdcc3e62008-11-13 09:08:33 +0000283 const std::vector<Record*> *LHSVec = &LHS.first;
284 const std::vector<Record*> *RHSVec = &RHS.first;
285 unsigned RHSSize = RHSVec->size();
286 unsigned LHSSize = LHSVec->size();
287
Chris Lattner93dc92e2010-03-22 20:56:36 +0000288 for (; i != LHSSize; ++i) {
Bill Wendlingcdcc3e62008-11-13 09:08:33 +0000289 if (i == RHSSize) return false; // RHS is shorter than LHS.
290 if ((*LHSVec)[i] != (*RHSVec)[i])
291 return (*LHSVec)[i]->getName() < (*RHSVec)[i]->getName();
Chris Lattner93dc92e2010-03-22 20:56:36 +0000292 }
Bill Wendlingcdcc3e62008-11-13 09:08:33 +0000293
Bill Wendling023422a2008-11-13 12:03:00 +0000294 if (i != RHSSize) return true;
Bill Wendlingcdcc3e62008-11-13 09:08:33 +0000295
296 i = 0;
297 LHSVec = &LHS.second;
298 RHSVec = &RHS.second;
299 RHSSize = RHSVec->size();
300 LHSSize = LHSVec->size();
301
302 for (i = 0; i != LHSSize; ++i) {
303 if (i == RHSSize) return false; // RHS is shorter than LHS.
304 if ((*LHSVec)[i] != (*RHSVec)[i])
305 return (*LHSVec)[i]->getName() < (*RHSVec)[i]->getName();
306 }
307
308 return i != RHSSize;
Chris Lattnerc4d9b242006-03-31 04:24:58 +0000309 }
310 };
311}
312
Chris Lattnerf97a00e2006-03-09 22:05:04 +0000313void IntrinsicEmitter::EmitVerifier(const std::vector<CodeGenIntrinsic> &Ints,
Daniel Dunbar1a551802009-07-03 00:10:29 +0000314 raw_ostream &OS) {
Chris Lattnerf97a00e2006-03-09 22:05:04 +0000315 OS << "// Verifier::visitIntrinsicFunctionCall code.\n";
316 OS << "#ifdef GET_INTRINSIC_VERIFIER\n";
317 OS << " switch (ID) {\n";
318 OS << " default: assert(0 && \"Invalid intrinsic!\");\n";
Chris Lattnerc4d9b242006-03-31 04:24:58 +0000319
320 // This checking can emit a lot of very common code. To reduce the amount of
321 // code that we emit, batch up cases that have identical types. This avoids
322 // problems where GCC can run out of memory compiling Verifier.cpp.
Bill Wendlingcdcc3e62008-11-13 09:08:33 +0000323 typedef std::map<RecPair, std::vector<unsigned>, RecordListComparator> MapTy;
Chris Lattnerc4d9b242006-03-31 04:24:58 +0000324 MapTy UniqueArgInfos;
325
326 // Compute the unique argument type info.
327 for (unsigned i = 0, e = Ints.size(); i != e; ++i)
Bill Wendlingcdcc3e62008-11-13 09:08:33 +0000328 UniqueArgInfos[make_pair(Ints[i].IS.RetTypeDefs,
329 Ints[i].IS.ParamTypeDefs)].push_back(i);
Chris Lattnerc4d9b242006-03-31 04:24:58 +0000330
331 // Loop through the array, emitting one comparison for each batch.
332 for (MapTy::iterator I = UniqueArgInfos.begin(),
333 E = UniqueArgInfos.end(); I != E; ++I) {
Bill Wendlingcdcc3e62008-11-13 09:08:33 +0000334 for (unsigned i = 0, e = I->second.size(); i != e; ++i)
Chris Lattnerc4d9b242006-03-31 04:24:58 +0000335 OS << " case Intrinsic::" << Ints[I->second[i]].EnumName << ":\t\t// "
336 << Ints[I->second[i]].Name << "\n";
Chris Lattnerf124b462006-03-31 04:48:26 +0000337
Bill Wendlingcdcc3e62008-11-13 09:08:33 +0000338 const RecPair &ArgTypes = I->first;
339 const std::vector<Record*> &RetTys = ArgTypes.first;
340 const std::vector<Record*> &ParamTys = ArgTypes.second;
Bob Wilson09b13662009-07-29 16:35:59 +0000341 std::vector<unsigned> OverloadedTypeIndices;
Bill Wendlingcdcc3e62008-11-13 09:08:33 +0000342
343 OS << " VerifyIntrinsicPrototype(ID, IF, " << RetTys.size() << ", "
344 << ParamTys.size();
345
346 // Emit return types.
347 for (unsigned j = 0, je = RetTys.size(); j != je; ++j) {
348 Record *ArgType = RetTys[j];
349 OS << ", ";
350
Chandler Carruth69940402007-08-04 01:51:18 +0000351 if (ArgType->isSubClassOf("LLVMMatchType")) {
352 unsigned Number = ArgType->getValueAsInt("Number");
Bob Wilson09b13662009-07-29 16:35:59 +0000353 assert(Number < OverloadedTypeIndices.size() &&
354 "Invalid matching number!");
355 Number = OverloadedTypeIndices[Number];
Bob Wilsonbc039792009-01-07 00:09:01 +0000356 if (ArgType->isSubClassOf("LLVMExtendedElementVectorType"))
357 OS << "~(ExtendedElementVectorType | " << Number << ")";
358 else if (ArgType->isSubClassOf("LLVMTruncatedElementVectorType"))
359 OS << "~(TruncatedElementVectorType | " << Number << ")";
360 else
361 OS << "~" << Number;
Chandler Carruth69940402007-08-04 01:51:18 +0000362 } else {
Owen Anderson825b72b2009-08-11 20:47:22 +0000363 MVT::SimpleValueType VT = getValueType(ArgType->getValueAsDef("VT"));
Chandler Carruth69940402007-08-04 01:51:18 +0000364 OS << getEnumName(VT);
Bill Wendlingcdcc3e62008-11-13 09:08:33 +0000365
Bob Wilson61fc4cf2009-08-11 01:14:02 +0000366 if (EVT(VT).isOverloaded())
Bob Wilson09b13662009-07-29 16:35:59 +0000367 OverloadedTypeIndices.push_back(j);
368
Owen Anderson825b72b2009-08-11 20:47:22 +0000369 if (VT == MVT::isVoid && j != 0 && j != je - 1)
Jim Laskey95d97b92007-02-06 18:30:58 +0000370 throw "Var arg type not last argument";
Jim Laskey95d97b92007-02-06 18:30:58 +0000371 }
Bill Wendlingcdcc3e62008-11-13 09:08:33 +0000372 }
373
374 // Emit the parameter types.
375 for (unsigned j = 0, je = ParamTys.size(); j != je; ++j) {
376 Record *ArgType = ParamTys[j];
377 OS << ", ";
378
379 if (ArgType->isSubClassOf("LLVMMatchType")) {
380 unsigned Number = ArgType->getValueAsInt("Number");
Bob Wilson09b13662009-07-29 16:35:59 +0000381 assert(Number < OverloadedTypeIndices.size() &&
382 "Invalid matching number!");
383 Number = OverloadedTypeIndices[Number];
Bob Wilsonbc039792009-01-07 00:09:01 +0000384 if (ArgType->isSubClassOf("LLVMExtendedElementVectorType"))
385 OS << "~(ExtendedElementVectorType | " << Number << ")";
386 else if (ArgType->isSubClassOf("LLVMTruncatedElementVectorType"))
387 OS << "~(TruncatedElementVectorType | " << Number << ")";
388 else
389 OS << "~" << Number;
Bill Wendlingcdcc3e62008-11-13 09:08:33 +0000390 } else {
Owen Anderson825b72b2009-08-11 20:47:22 +0000391 MVT::SimpleValueType VT = getValueType(ArgType->getValueAsDef("VT"));
Bill Wendlingcdcc3e62008-11-13 09:08:33 +0000392 OS << getEnumName(VT);
393
Bob Wilson61fc4cf2009-08-11 01:14:02 +0000394 if (EVT(VT).isOverloaded())
Bob Wilson09b13662009-07-29 16:35:59 +0000395 OverloadedTypeIndices.push_back(j + RetTys.size());
396
Owen Anderson825b72b2009-08-11 20:47:22 +0000397 if (VT == MVT::isVoid && j != 0 && j != je - 1)
Bill Wendlingcdcc3e62008-11-13 09:08:33 +0000398 throw "Var arg type not last argument";
399 }
Jim Laskey95d97b92007-02-06 18:30:58 +0000400 }
401
Chandler Carruth69940402007-08-04 01:51:18 +0000402 OS << ");\n";
Chris Lattnerf97a00e2006-03-09 22:05:04 +0000403 OS << " break;\n";
404 }
405 OS << " }\n";
406 OS << "#endif\n\n";
Chris Lattner9b843b22006-03-09 20:34:19 +0000407}
408
Jim Laskey95af5922007-02-07 20:38:26 +0000409void IntrinsicEmitter::EmitGenerator(const std::vector<CodeGenIntrinsic> &Ints,
Daniel Dunbar1a551802009-07-03 00:10:29 +0000410 raw_ostream &OS) {
Jim Laskey95af5922007-02-07 20:38:26 +0000411 OS << "// Code for generating Intrinsic function declarations.\n";
412 OS << "#ifdef GET_INTRINSIC_GENERATOR\n";
413 OS << " switch (id) {\n";
414 OS << " default: assert(0 && \"Invalid intrinsic!\");\n";
415
416 // Similar to GET_INTRINSIC_VERIFIER, batch up cases that have identical
417 // types.
Bill Wendlingcdcc3e62008-11-13 09:08:33 +0000418 typedef std::map<RecPair, std::vector<unsigned>, RecordListComparator> MapTy;
Jim Laskey95af5922007-02-07 20:38:26 +0000419 MapTy UniqueArgInfos;
420
421 // Compute the unique argument type info.
422 for (unsigned i = 0, e = Ints.size(); i != e; ++i)
Bill Wendlingcdcc3e62008-11-13 09:08:33 +0000423 UniqueArgInfos[make_pair(Ints[i].IS.RetTypeDefs,
424 Ints[i].IS.ParamTypeDefs)].push_back(i);
Jim Laskey95af5922007-02-07 20:38:26 +0000425
426 // Loop through the array, emitting one generator for each batch.
Dale Johannesen49de9822009-02-05 01:49:45 +0000427 std::string IntrinsicStr = TargetPrefix + "Intrinsic::";
428
Jim Laskey95af5922007-02-07 20:38:26 +0000429 for (MapTy::iterator I = UniqueArgInfos.begin(),
430 E = UniqueArgInfos.end(); I != E; ++I) {
Bill Wendlingcdcc3e62008-11-13 09:08:33 +0000431 for (unsigned i = 0, e = I->second.size(); i != e; ++i)
Dale Johannesen49de9822009-02-05 01:49:45 +0000432 OS << " case " << IntrinsicStr << Ints[I->second[i]].EnumName
433 << ":\t\t// " << Ints[I->second[i]].Name << "\n";
Jim Laskey95af5922007-02-07 20:38:26 +0000434
Bill Wendlingcdcc3e62008-11-13 09:08:33 +0000435 const RecPair &ArgTypes = I->first;
436 const std::vector<Record*> &RetTys = ArgTypes.first;
437 const std::vector<Record*> &ParamTys = ArgTypes.second;
438
439 unsigned N = ParamTys.size();
Jim Laskey95af5922007-02-07 20:38:26 +0000440
Chandler Carruth69940402007-08-04 01:51:18 +0000441 if (N > 1 &&
Owen Anderson825b72b2009-08-11 20:47:22 +0000442 getValueType(ParamTys[N - 1]->getValueAsDef("VT")) == MVT::isVoid) {
Jim Laskey95af5922007-02-07 20:38:26 +0000443 OS << " IsVarArg = true;\n";
444 --N;
445 }
Bill Wendlingcdcc3e62008-11-13 09:08:33 +0000446
Reid Spencer84c614d2007-05-22 19:30:31 +0000447 unsigned ArgNo = 0;
Jim Laskey95af5922007-02-07 20:38:26 +0000448 OS << " ResultTy = ";
Bill Wendlingcdcc3e62008-11-13 09:08:33 +0000449 EmitTypeGenerate(OS, RetTys, ArgNo);
Jim Laskey95af5922007-02-07 20:38:26 +0000450 OS << ";\n";
451
Bill Wendlingcdcc3e62008-11-13 09:08:33 +0000452 for (unsigned j = 0; j != N; ++j) {
Jim Laskey95af5922007-02-07 20:38:26 +0000453 OS << " ArgTys.push_back(";
Bill Wendlingcdcc3e62008-11-13 09:08:33 +0000454 EmitTypeGenerate(OS, ParamTys[j], ArgNo);
Jim Laskey95af5922007-02-07 20:38:26 +0000455 OS << ");\n";
456 }
Bill Wendlingcdcc3e62008-11-13 09:08:33 +0000457
Jim Laskey95af5922007-02-07 20:38:26 +0000458 OS << " break;\n";
459 }
Bill Wendlingcdcc3e62008-11-13 09:08:33 +0000460
Jim Laskey95af5922007-02-07 20:38:26 +0000461 OS << " }\n";
462 OS << "#endif\n\n";
463}
464
Chris Lattner048ffb22009-01-12 01:18:58 +0000465/// EmitAttributes - This emits the Intrinsic::getAttributes method.
Chris Lattner4e5f3592006-03-09 22:37:52 +0000466void IntrinsicEmitter::
Daniel Dunbar1a551802009-07-03 00:10:29 +0000467EmitAttributes(const std::vector<CodeGenIntrinsic> &Ints, raw_ostream &OS) {
Duncan Sandsa3355ff2007-12-03 20:06:50 +0000468 OS << "// Add parameter attributes that are not common to all intrinsics.\n";
469 OS << "#ifdef GET_INTRINSIC_ATTRIBUTES\n";
Dale Johannesen49de9822009-02-05 01:49:45 +0000470 if (TargetOnly)
471 OS << "static AttrListPtr getAttributes(" << TargetPrefix
472 << "Intrinsic::ID id) {";
473 else
474 OS << "AttrListPtr Intrinsic::getAttributes(ID id) {";
Chris Lattner048ffb22009-01-12 01:18:58 +0000475 OS << " // No intrinsic can throw exceptions.\n";
476 OS << " Attributes Attr = Attribute::NoUnwind;\n";
Duncan Sandsa3355ff2007-12-03 20:06:50 +0000477 OS << " switch (id) {\n";
Chris Lattner7056de32006-03-24 01:13:55 +0000478 OS << " default: break;\n";
Chris Lattner10dae942009-01-12 01:27:55 +0000479 unsigned MaxArgAttrs = 0;
Chris Lattner7056de32006-03-24 01:13:55 +0000480 for (unsigned i = 0, e = Ints.size(); i != e; ++i) {
Chris Lattner10dae942009-01-12 01:27:55 +0000481 MaxArgAttrs =
482 std::max(MaxArgAttrs, unsigned(Ints[i].ArgumentAttributes.size()));
Chris Lattner7056de32006-03-24 01:13:55 +0000483 switch (Ints[i].ModRef) {
484 default: break;
485 case CodeGenIntrinsic::NoMem:
Dale Johannesen49de9822009-02-05 01:49:45 +0000486 OS << " case " << TargetPrefix << "Intrinsic::" << Ints[i].EnumName
487 << ":\n";
Chris Lattner7056de32006-03-24 01:13:55 +0000488 break;
489 }
490 }
Devang Patel05988662008-09-25 21:00:45 +0000491 OS << " Attr |= Attribute::ReadNone; // These do not access memory.\n";
Duncan Sandsa3355ff2007-12-03 20:06:50 +0000492 OS << " break;\n";
Chris Lattner4e5f3592006-03-09 22:37:52 +0000493 for (unsigned i = 0, e = Ints.size(); i != e; ++i) {
494 switch (Ints[i].ModRef) {
Chris Lattner022f64f2006-03-13 23:08:44 +0000495 default: break;
Chris Lattner022f64f2006-03-13 23:08:44 +0000496 case CodeGenIntrinsic::ReadArgMem:
497 case CodeGenIntrinsic::ReadMem:
Dale Johannesen49de9822009-02-05 01:49:45 +0000498 OS << " case " << TargetPrefix << "Intrinsic::" << Ints[i].EnumName
499 << ":\n";
Chris Lattner022f64f2006-03-13 23:08:44 +0000500 break;
Chris Lattner4e5f3592006-03-09 22:37:52 +0000501 }
502 }
Devang Patel05988662008-09-25 21:00:45 +0000503 OS << " Attr |= Attribute::ReadOnly; // These do not write memory.\n";
Duncan Sandsa3355ff2007-12-03 20:06:50 +0000504 OS << " break;\n";
Chris Lattner4e5f3592006-03-09 22:37:52 +0000505 OS << " }\n";
Chris Lattner10dae942009-01-12 01:27:55 +0000506 OS << " AttributeWithIndex AWI[" << MaxArgAttrs+1 << "];\n";
Chris Lattnerd4a27002009-01-12 02:41:37 +0000507 OS << " unsigned NumAttrs = 0;\n";
Chris Lattner10dae942009-01-12 01:27:55 +0000508 OS << " switch (id) {\n";
509 OS << " default: break;\n";
510
511 // Add argument attributes for any intrinsics that have them.
512 for (unsigned i = 0, e = Ints.size(); i != e; ++i) {
513 if (Ints[i].ArgumentAttributes.empty()) continue;
514
Dale Johannesen49de9822009-02-05 01:49:45 +0000515 OS << " case " << TargetPrefix << "Intrinsic::" << Ints[i].EnumName
516 << ":\n";
Chris Lattner10dae942009-01-12 01:27:55 +0000517
518 std::vector<std::pair<unsigned, CodeGenIntrinsic::ArgAttribute> > ArgAttrs =
519 Ints[i].ArgumentAttributes;
520 // Sort by argument index.
521 std::sort(ArgAttrs.begin(), ArgAttrs.end());
522
523 unsigned NumArgsWithAttrs = 0;
524
Chris Lattnerd4a27002009-01-12 02:41:37 +0000525 while (!ArgAttrs.empty()) {
526 unsigned ArgNo = ArgAttrs[0].first;
527
528 OS << " AWI[" << NumArgsWithAttrs++ << "] = AttributeWithIndex::get("
529 << ArgNo+1 << ", 0";
530
531 while (!ArgAttrs.empty() && ArgAttrs[0].first == ArgNo) {
532 switch (ArgAttrs[0].second) {
533 default: assert(0 && "Unknown arg attribute");
534 case CodeGenIntrinsic::NoCapture:
535 OS << "|Attribute::NoCapture";
536 break;
537 }
538 ArgAttrs.erase(ArgAttrs.begin());
539 }
540 OS << ");\n";
541 }
Chris Lattner10dae942009-01-12 01:27:55 +0000542
Chris Lattnerd4a27002009-01-12 02:41:37 +0000543 OS << " NumAttrs = " << NumArgsWithAttrs << ";\n";
Chris Lattner10dae942009-01-12 01:27:55 +0000544 OS << " break;\n";
545 }
546
547 OS << " }\n";
Chris Lattnerd4a27002009-01-12 02:41:37 +0000548 OS << " AWI[NumAttrs] = AttributeWithIndex::get(~0, Attr);\n";
549 OS << " return AttrListPtr::get(AWI, NumAttrs+1);\n";
Chris Lattner048ffb22009-01-12 01:18:58 +0000550 OS << "}\n";
Chris Lattnerd4a27002009-01-12 02:41:37 +0000551 OS << "#endif // GET_INTRINSIC_ATTRIBUTES\n\n";
Chris Lattner4e5f3592006-03-09 22:37:52 +0000552}
Chris Lattner022f64f2006-03-13 23:08:44 +0000553
Duncan Sandsd869b382009-02-14 10:56:35 +0000554/// EmitModRefBehavior - Determine intrinsic alias analysis mod/ref behavior.
555void IntrinsicEmitter::
Daniel Dunbar1a551802009-07-03 00:10:29 +0000556EmitModRefBehavior(const std::vector<CodeGenIntrinsic> &Ints, raw_ostream &OS){
Duncan Sandsd869b382009-02-14 10:56:35 +0000557 OS << "// Determine intrinsic alias analysis mod/ref behavior.\n";
558 OS << "#ifdef GET_INTRINSIC_MODREF_BEHAVIOR\n";
Duncan Sands7c422ac2010-01-06 08:45:52 +0000559 OS << "switch (iid) {\n";
Duncan Sandsd869b382009-02-14 10:56:35 +0000560 OS << "default:\n return UnknownModRefBehavior;\n";
561 for (unsigned i = 0, e = Ints.size(); i != e; ++i) {
Dan Gohman7365c092010-08-05 23:36:21 +0000562 if (Ints[i].ModRef == CodeGenIntrinsic::ReadWriteMem)
Duncan Sandsd869b382009-02-14 10:56:35 +0000563 continue;
564 OS << "case " << TargetPrefix << "Intrinsic::" << Ints[i].EnumName
565 << ":\n";
566 switch (Ints[i].ModRef) {
567 default:
568 assert(false && "Unknown Mod/Ref type!");
569 case CodeGenIntrinsic::NoMem:
570 OS << " return DoesNotAccessMemory;\n";
571 break;
572 case CodeGenIntrinsic::ReadArgMem:
573 case CodeGenIntrinsic::ReadMem:
574 OS << " return OnlyReadsMemory;\n";
575 break;
Dan Gohman7365c092010-08-05 23:36:21 +0000576 case CodeGenIntrinsic::ReadWriteArgMem:
Duncan Sandsd869b382009-02-14 10:56:35 +0000577 OS << " return AccessesArguments;\n";
578 break;
579 }
580 }
581 OS << "}\n";
582 OS << "#endif // GET_INTRINSIC_MODREF_BEHAVIOR\n\n";
583}
584
Chris Lattner022f64f2006-03-13 23:08:44 +0000585void IntrinsicEmitter::
Daniel Dunbar1a551802009-07-03 00:10:29 +0000586EmitGCCBuiltinList(const std::vector<CodeGenIntrinsic> &Ints, raw_ostream &OS){
Chris Lattner022f64f2006-03-13 23:08:44 +0000587 OS << "// Get the GCC builtin that corresponds to an LLVM intrinsic.\n";
588 OS << "#ifdef GET_GCC_BUILTIN_NAME\n";
589 OS << " switch (F->getIntrinsicID()) {\n";
590 OS << " default: BuiltinName = \"\"; break;\n";
591 for (unsigned i = 0, e = Ints.size(); i != e; ++i) {
592 if (!Ints[i].GCCBuiltinName.empty()) {
593 OS << " case Intrinsic::" << Ints[i].EnumName << ": BuiltinName = \""
594 << Ints[i].GCCBuiltinName << "\"; break;\n";
595 }
596 }
597 OS << " }\n";
598 OS << "#endif\n\n";
Reid Spencer767a25b2006-03-14 05:59:52 +0000599}
Chris Lattner3f8b8912006-03-15 01:33:26 +0000600
Chris Lattner331bf922008-01-04 04:38:35 +0000601/// EmitTargetBuiltins - All of the builtins in the specified map are for the
602/// same target, and we already checked it.
603static void EmitTargetBuiltins(const std::map<std::string, std::string> &BIM,
Dale Johannesen49de9822009-02-05 01:49:45 +0000604 const std::string &TargetPrefix,
Daniel Dunbar1a551802009-07-03 00:10:29 +0000605 raw_ostream &OS) {
Chris Lattner331bf922008-01-04 04:38:35 +0000606
Chris Lattner298b1762010-09-06 03:14:45 +0000607 std::vector<StringMatcher::StringPair> Results;
Chris Lattner331bf922008-01-04 04:38:35 +0000608
Chris Lattner298b1762010-09-06 03:14:45 +0000609 for (std::map<std::string, std::string>::const_iterator I = BIM.begin(),
610 E = BIM.end(); I != E; ++I) {
611 std::string ResultCode =
612 "return " + TargetPrefix + "Intrinsic::" + I->second + ";";
613 Results.push_back(StringMatcher::StringPair(I->first, ResultCode));
Chris Lattner331bf922008-01-04 04:38:35 +0000614 }
Chris Lattner298b1762010-09-06 03:14:45 +0000615
616 StringMatcher("BuiltinName", Results, OS).Emit();
Chris Lattner331bf922008-01-04 04:38:35 +0000617}
618
619
Chris Lattner3f8b8912006-03-15 01:33:26 +0000620void IntrinsicEmitter::
621EmitIntrinsicToGCCBuiltinMap(const std::vector<CodeGenIntrinsic> &Ints,
Daniel Dunbar1a551802009-07-03 00:10:29 +0000622 raw_ostream &OS) {
Chris Lattnerfa0fba12008-01-02 21:24:22 +0000623 typedef std::map<std::string, std::map<std::string, std::string> > BIMTy;
Chris Lattner3f8b8912006-03-15 01:33:26 +0000624 BIMTy BuiltinMap;
625 for (unsigned i = 0, e = Ints.size(); i != e; ++i) {
626 if (!Ints[i].GCCBuiltinName.empty()) {
Chris Lattnerfa0fba12008-01-02 21:24:22 +0000627 // Get the map for this target prefix.
628 std::map<std::string, std::string> &BIM =BuiltinMap[Ints[i].TargetPrefix];
629
630 if (!BIM.insert(std::make_pair(Ints[i].GCCBuiltinName,
631 Ints[i].EnumName)).second)
Chris Lattner3f8b8912006-03-15 01:33:26 +0000632 throw "Intrinsic '" + Ints[i].TheDef->getName() +
633 "': duplicate GCC builtin name!";
634 }
635 }
636
637 OS << "// Get the LLVM intrinsic that corresponds to a GCC builtin.\n";
638 OS << "// This is used by the C front-end. The GCC builtin name is passed\n";
639 OS << "// in as BuiltinName, and a target prefix (e.g. 'ppc') is passed\n";
640 OS << "// in as TargetPrefix. The result is assigned to 'IntrinsicID'.\n";
641 OS << "#ifdef GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN\n";
Dale Johannesen49de9822009-02-05 01:49:45 +0000642
643 if (TargetOnly) {
644 OS << "static " << TargetPrefix << "Intrinsic::ID "
645 << "getIntrinsicForGCCBuiltin(const char "
Chris Lattner298b1762010-09-06 03:14:45 +0000646 << "*TargetPrefixStr, const char *BuiltinNameStr) {\n";
Dale Johannesen49de9822009-02-05 01:49:45 +0000647 } else {
648 OS << "Intrinsic::ID Intrinsic::getIntrinsicForGCCBuiltin(const char "
Chris Lattner298b1762010-09-06 03:14:45 +0000649 << "*TargetPrefixStr, const char *BuiltinNameStr) {\n";
Dale Johannesen49de9822009-02-05 01:49:45 +0000650 }
651
Chris Lattner298b1762010-09-06 03:14:45 +0000652 OS << " StringRef BuiltinName(BuiltinNameStr);\n";
653 OS << " StringRef TargetPrefix(TargetPrefixStr);\n\n";
Chris Lattner331bf922008-01-04 04:38:35 +0000654
Chris Lattner3f8b8912006-03-15 01:33:26 +0000655 // Note: this could emit significantly better code if we cared.
656 for (BIMTy::iterator I = BuiltinMap.begin(), E = BuiltinMap.end();I != E;++I){
Chris Lattnerfa0fba12008-01-02 21:24:22 +0000657 OS << " ";
658 if (!I->first.empty())
Chris Lattner298b1762010-09-06 03:14:45 +0000659 OS << "if (TargetPrefix == \"" << I->first << "\") ";
Chris Lattnerfa0fba12008-01-02 21:24:22 +0000660 else
661 OS << "/* Target Independent Builtins */ ";
662 OS << "{\n";
663
Chris Lattnerfa0fba12008-01-02 21:24:22 +0000664 // Emit the comparisons for this target prefix.
Dale Johannesen49de9822009-02-05 01:49:45 +0000665 EmitTargetBuiltins(I->second, TargetPrefix, OS);
Chris Lattnerfa0fba12008-01-02 21:24:22 +0000666 OS << " }\n";
Chris Lattner3f8b8912006-03-15 01:33:26 +0000667 }
Chris Lattner298b1762010-09-06 03:14:45 +0000668 OS << " return ";
669 if (!TargetPrefix.empty())
670 OS << "(" << TargetPrefix << "Intrinsic::ID)";
671 OS << "Intrinsic::not_intrinsic;\n";
Dale Johannesen49de9822009-02-05 01:49:45 +0000672 OS << "}\n";
Chris Lattner3f8b8912006-03-15 01:33:26 +0000673 OS << "#endif\n\n";
674}