Remove outermost loop parameter.
[official-gcc/graphite-test-results.git] / libpcp / pcp_emitter.cc
blob3c5f1f4b8fcfdb5e8f32f2ed3f92ab986d43b255
1 // Copyright (C) 2009 Free Software Foundation, Inc.
2 // Contributed by Jan Sjodin <jan.sjodin@amd.com>.
4 // This file is part of the Polyhedral Compilation Package Library (libpcp).
6 // Libpcp is free software; you can redistribute it and/or modify it
7 // under the terms of the GNU Lesser General Public License as published by
8 // the Free Software Foundation; either version 2.1 of the License, or
9 // (at your option) any later version.
11 // Libpcp is distributed in the hope that it will be useful, but WITHOUT ANY
12 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
14 // more details.
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with libpcp; see the file COPYING.LIB. If not, write to the
18 // Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 // MA 02110-1301, USA.
21 // As a special exception, if you link this library with other files, some
22 // of which are compiled with GCC, to produce an executable, this library
23 // does not by itself cause the resulting executable to be covered by the
24 // GNU General Public License. This exception does not however invalidate
25 // any other reasons why the executable file might be covered by the GNU
26 // General Public License.
28 #include "pcp_error.h"
29 #include "pcp_alloc.h"
30 #include "pcp_emitter.h"
32 // PCP Emit Context
34 // Set string buffer of CONTEXT to STRINGBuffer.
35 void
36 PcpEmitter::setStringBuffer(PcpStringBuffer* stringBuffer)
38 this->stringBuffer = stringBuffer;
41 // Get string buffer of CONTEXT.
42 PcpStringBuffer*
43 PcpEmitter::getStringBuffer()
45 return this->stringBuffer;
48 void
49 PcpEmitter::setTagFilterSet(PcpSet<const char*>* tagFilterSet)
51 this->tagFilterSet = tagFilterSet;
54 PcpSet<const char*>*
55 PcpEmitter::getTagFilterSet()
57 return this->tagFilterSet;
60 bool
61 PcpEmitter::tagIsFiltered(const char* tag)
63 PcpSet<const char*>* tagSet = this->getTagFilterSet();
64 PcpIterator<const char*>* iter = tagSet->getIterator();
66 for(;iter->hasNext();iter->next())
68 const char* memberTag = iter->get();
69 if(strcmp(memberTag, tag) == 0)
70 return true;
72 delete iter;
73 return false;
75 // Set indent level of CONTEXT to INDENT.
76 void
77 PcpEmitter::setIndent(int indent)
79 this->indent = indent;
82 // Get indent level of CONTEXT.
83 int
84 PcpEmitter::getIndent()
86 return this->indent;
89 // Increment indent level of CONTEXT.
90 void
91 PcpEmitter::increment()
93 this->setIndent(this->getIndent() + 1);
96 // Decrement indent level of CONTEXT.
97 void
98 PcpEmitter::decrement()
100 this->setIndent(this->getIndent() - 1);
103 // Write indent spaces.
104 void
105 PcpEmitter::writeIndent()
107 int i;
108 int indent = this->getIndent();
109 for(i = 0; i < indent; i++)
110 this->getStringBuffer()->append(" ");
113 // Write newline.
114 void
115 PcpEmitter::writeNewline()
117 this->getStringBuffer()->newline();
120 // Write STRING.
121 void
122 PcpEmitter::writeString(const char* string)
124 this->getStringBuffer()->append(string);
127 // Write indented STRING.
128 void
129 PcpEmitter::writeStringIndent(const char* string)
131 this->writeIndent();
132 this->getStringBuffer()->append(string);
135 // Write VALUE.
136 void
137 PcpEmitter::writeInt(int value)
139 this->getStringBuffer()->appendInt(value);
142 // Convert CONTEXT to string.
143 const char*
144 PcpEmitter::stringBufferToString()
146 return
147 this->getStringBuffer()->toString();
151 // Write OBJECT annots.
152 void
153 PcpEmitter::emitObjectAnnots(PcpObject* object)
155 bool first = true;
156 PcpAnnotSet* annots = object->getAnnots();
157 int numAnnots;
158 int i;
160 if(annots == NULL)
161 return;
163 numAnnots = annots->getNumAnnots();
166 for(i = 0; i < numAnnots; i++)
168 PcpAnnotTerm* annotTerm = annots->getAnnot(i);
171 if(this->tagIsFiltered(annotTerm->getTag()))
172 continue;
174 if(first)
176 this->writeString(" | ");
177 first = false;
179 else
180 this->writeString(", ");
181 this->emitAnnotTerm(annotTerm);
185 // Write ANNOT.
186 void
187 PcpEmitter::emitAnnot(PcpAnnot* annot)
189 if(annot->isAnnotInt())
190 this->emitAnnotInt(annot->toAnnotInt());
191 else if(annot->isAnnotString())
192 this->emitAnnotString(annot->toAnnotString());
193 else if(annot->isAnnotObject())
194 this->emitAnnotObject(annot->toAnnotObject());
195 else
196 this->emitAnnotTerm(annot->toAnnotTerm());
199 void PcpEmitter::addFilteredTag(const char* tag)
201 this->getTagFilterSet()->insert(tag);
205 const char* PcpEmitter::bufferToString()
207 return this->stringBufferToString();
210 // Write ANNOTInt.
211 void
212 PcpEmitter::emitAnnotInt(PcpAnnotInt* annotInt)
214 this->writeInt(annotInt->getValue());
217 // Write ANNOTString.
218 void
219 PcpEmitter::emitAnnotString(PcpAnnotString* annotString)
221 this->writeString(annotString->getString());
224 // Write ANNOTObject.
225 void
226 PcpEmitter::emitAnnotObject(PcpAnnotObject* annotObject)
228 PcpObject* object = annotObject->getObject();
229 pcpAssert(object->getName() != NULL);
230 this->writeString(object->getName());
233 // Write ANNOTTerm.
234 void
235 PcpEmitter::emitAnnotTerm(PcpAnnotTerm* annotTerm)
237 int numArguments = annotTerm->getNumArguments();
238 int i;
239 bool first = true;
241 this->writeString(annotTerm->getTag());
242 this->writeString("(");
244 for(i = 0; i < numArguments; i++)
246 if(first)
247 first = false;
248 else
249 this->writeString(", ");
250 this->emitAnnot(annotTerm->getArgument(i));
253 this->writeString( ")");
256 // Write TYPE.
257 void
258 PcpEmitter::emitArrayTypeDef(PcpArrayType* type)
260 bool first = true;
261 int numDims = type->getNumDimensions();
262 int i;
264 this->writeString("array(");
265 for(i = 0; i < numDims; i++)
267 if(first)
268 first = false;
269 else
270 this->writeString(", ");
271 this->emitExpr(type->getDimension(i));
273 this->emitObjectAnnots(type);
274 this->writeString(")");
277 // Write TYPE.
278 void
279 PcpEmitter::emitArrayTypeUse(PcpArrayType* type)
281 const char* name = type->getName();
282 if(name != NULL)
283 this->writeString(name);
284 else
285 this->emitArrayTypeDef(type);
288 // Write EXPR.
289 void
290 PcpEmitter::emitExpr(PcpExpr* expr)
292 if(expr->isParameter())
293 this->emitParameterUse(expr->toParameter());
294 else if(expr->isConstant())
295 this->emitConstantUse(expr->toConstant());
296 else if(expr->isIv())
297 this->emitIvUse(expr->toIv());
298 else if(expr->isArith())
299 this->emitArith(expr->toArith());
300 else
301 pcpAssert(false);
304 const char*
305 PcpEmitter::emitGetBoolOperatorString(PcpBoolArithOperator oper)
307 return((oper.isBoolAnd()) ? "and"
308 :(oper.isBoolOr()) ? "or"
309 : "unknown");
312 void
313 PcpEmitter::emitObjectNameBinding(PcpObject* object)
315 const char* name = object->getName();
317 if(name != NULL)
319 this->writeString(name);
320 this->writeString(" <- ");
324 void
325 PcpEmitter::emitBoolArith(PcpBoolArith* boolArith)
327 const char* operatorString =
328 this->emitGetBoolOperatorString(boolArith->getOperator());
329 int numOperands = boolArith->getNumOperands();
330 bool first = true;
331 int i;
333 this->emitObjectNameBinding(boolArith);
334 this->writeString(operatorString);
335 this->writeString("(");
336 for(i = 0; i < numOperands; i++)
338 if(first)
339 first = false;
340 else
341 this->writeString(", ");
342 this->emitBoolExpr(boolArith->getOperand(i));
344 this->writeString(")");
347 // Write BOOLExpr.
348 void
349 PcpEmitter::emitBoolExpr(PcpBoolExpr* boolExpr)
351 if(boolExpr->isCompare())
352 this->emitCompare(boolExpr->toCompare());
353 else if(boolExpr->isBoolArith())
354 this->emitBoolArith(boolExpr->toBoolArith());
355 else
356 pcpAssert(false);
359 void
360 PcpEmitter::emitCompareOperator(PcpCompareOperator oper)
362 const char* operatorString = NULL;
363 if(oper.isEqual())
364 operatorString = "eq";
365 else if(oper.isGreaterEqual())
366 operatorString = "ge";
367 else
368 pcpAssert(false);
370 this->writeString(operatorString);
373 // Write COMPARE
374 void
375 PcpEmitter::emitCompare(PcpCompare* compare)
377 this->emitCompareOperator(compare->getOperator());
378 this->writeString("(");
379 this->emitExpr(compare->getLhs());
380 this->writeString(", ");
381 this->emitExpr(compare->getRhs());
382 this->writeString(")");
385 void
386 PcpEmitter::emitObjectNameBindingIndent(PcpObject* object)
388 this->writeIndent();
389 this->emitObjectNameBinding(object);
392 // Write CONSTANT declaration.
393 void
394 PcpEmitter::emitConstantDecl(PcpConstant* constant)
396 const char* name = constant->getName();
397 if(name != NULL)
399 this->writeString(name);
400 this->writeString(" <- constant(");
401 this->writeInt(constant->getValue());
402 this->emitObjectAnnots(constant);
403 this->writeString(")");
407 // Write CONSTANT use string.
408 void
409 PcpEmitter::emitConstantUse(PcpConstant* constant)
411 const char* name = constant->getName();
412 if(name != NULL)
413 this->writeString(name);
414 else
415 this->writeInt(constant->getValue());
418 // Write IV declaration.
419 void
420 PcpEmitter::emitIvDecl(PcpIv* iv)
422 this->writeString(iv->getName());
423 this->writeString(" <- iv(");
424 this->emitObjectAnnots(iv);
425 this->writeString(")");
428 // Write IV use.
429 void
430 PcpEmitter::emitIvUse(PcpIv* iv)
432 this->writeString(iv->getName());
435 // Write VAR declaration.
436 void
437 PcpEmitter::emitVariableDecl(PcpVariable* var)
439 this->writeString(var->getName());
440 this->writeString(" <- variable(");
441 this->emitArrayTypeUse(var->getType());
442 this->emitObjectAnnots(var);
443 this->writeString(")");
446 // Write VAR use.
447 void
448 PcpEmitter::emitVariableUse(PcpVariable* var)
450 this->writeString(var->getName());
453 // Write PARAMETER declaration.
454 void
455 PcpEmitter::emitParameterDecl(PcpParameter* parameter)
457 this->writeString(parameter->getName());
458 this->writeString(" <- parameter(");
459 this->emitObjectAnnots(parameter);
460 this->writeString(")");
464 // Write PARAMETER use.
465 void
466 PcpEmitter::emitParameterUse(PcpParameter* parameter)
468 this->writeString(parameter->getName());
472 // Write ARITH.
473 const char*
474 PcpEmitter::emitGetOperatorString(PcpArithOperator oper)
476 const char* result = NULL;
477 if(oper.isAdd()) result = "+";
478 else if(oper.isMultiply()) result = "*";
479 else if(oper.isMin()) result = "min";
480 else if(oper.isMax()) result = "max";
481 else if(oper.isSubtract()) result = "-";
482 else if(oper.isFloor()) result = "floor";
483 else if(oper.isCeiling()) result = "ceil";
484 else if(oper.isUnknown()) result = "UNKNOWN";
485 else pcpAssert(false);
487 return result;
490 void
491 PcpEmitter::emitArith(PcpArith* arith)
493 const char* operatorString =
494 this->emitGetOperatorString(arith->getOperator());
495 int numOperands = arith->getNumOperands();
496 bool first = true;
497 int i;
499 this->emitObjectNameBinding(arith);
500 this->writeString(operatorString);
501 this->writeString("(");
502 for(i = 0; i < numOperands; i++)
504 if(first)
505 first = false;
506 else
507 this->writeString(", ");
508 this->emitExpr(arith->getOperand(i));
510 this->writeString(")");
515 // Write ACCESS.
516 void
517 PcpEmitter::emitArrayAccess(PcpArrayAccess* access)
519 int i;
520 int numSubscripts = access->getNumSubscripts();
521 const char* oper = access->isUse() ? "use" :
522 access->isDef() ? "def" :
523 access->isMaydef() ? "maydef" : "undefinedAccess";
525 this->emitObjectNameBinding(access);
527 this->writeString(oper);
528 this->writeString("(");
529 this->emitVariableUse(access->getBase());
531 for(i = 0; i < numSubscripts; i++)
533 this->writeString(", ");
534 this->emitExpr(access->getSubscript(i));
536 this->emitObjectAnnots(access);
537 this->writeString(")");
540 // Write COPY.
541 void
542 PcpEmitter::emitCopy(PcpCopy* copy)
544 this->emitObjectNameBindingIndent(copy);
545 this->writeString("copy(");
546 this->emitArrayAccess(copy->getDest());
547 this->writeString(", ");
548 this->emitArrayAccess(copy->getSrc());
549 this->emitObjectAnnots(copy);
550 this->writeString(")");
553 // Write USERSTMT.
554 void
555 PcpEmitter::emitUserStmt(PcpUserStmt* userStmt)
557 bool first = true;
558 int i;
559 int numAccesses = userStmt->getNumAccesses();
560 PcpArrayAccess* access;
562 this->writeStringIndent(userStmt->getName());
563 this->writeString("(");
565 for(i = 0; i < numAccesses; i++)
567 if(first)
568 first = false;
569 else
570 this->writeString(", ");
572 access = userStmt->getArrayAccess(i);
573 this->emitArrayAccess(access);
575 this->emitObjectAnnots(userStmt);
576 this->writeString(")");
579 // Write SEQUENCE.
580 void
581 PcpEmitter::emitSequence(PcpSequence* sequence)
583 int i;
584 int numStmts = sequence->getNumStmts();
585 bool first = true;
586 for(i = 0; i < numStmts; i++)
588 if(first)
589 first = false;
590 else
591 this->writeString("\n");
592 this->emitStmt(sequence->getStmt(i));
596 // Write STMT.
597 void
598 PcpEmitter::emitStmt(PcpStmt* stmt)
600 if(stmt->isCopy())
601 this->emitCopy(stmt->toCopy());
602 else if(stmt->isUserStmt())
603 this->emitUserStmt(stmt->toUserStmt());
604 else if(stmt->isSequence())
605 this->emitSequence(stmt->toSequence());
606 else if(stmt->isGuard())
607 this->emitGuard(stmt->toGuard());
608 else if(stmt->isLoop())
609 this->emitLoop(stmt->toLoop());
610 else
611 pcpAssert(false);
614 // Write GUARD.
615 void
616 PcpEmitter::emitGuard(PcpGuard* guard)
618 this->emitObjectNameBindingIndent(guard);
619 this->writeString("guard(");
620 this->emitBoolExpr(guard->getCondition());
621 this->emitObjectAnnots(guard);
622 this->writeString(")");
623 this->writeNewline();
624 this->writeStringIndent("{");
625 this->writeNewline();
627 this->increment();
628 this->emitStmt(guard->getBody());
629 this->decrement();
631 this->writeNewline();
632 this->writeStringIndent("}");
635 // Write LOOP.
636 void
637 PcpEmitter::emitLoop(PcpLoop* loop)
639 this->emitObjectNameBindingIndent(loop);
640 this->writeString("loop(");
641 this->emitIvDecl(loop->getIv());
642 this->writeString(", ");
643 this->emitExpr(loop->getStart());
644 this->writeString(", ");
645 this->emitBoolExpr(loop->getCondition());
646 this->writeString(", ");
647 this->emitConstantUse(loop->getStride());
648 this->emitObjectAnnots(loop);
649 this->writeString(")");
650 this->writeNewline();
651 this->writeStringIndent("{");
652 this->writeNewline();
654 this->increment();
655 this->emitStmt(loop->getBody());
656 this->decrement();
658 this->writeNewline();
659 this->writeStringIndent("}");
662 // Write SCOP inputs.
663 void
664 PcpEmitter::emitScopInputs(PcpScop* scop)
666 int numVariables = scop->getNumVariables();
667 bool first = true;
668 int i;
670 this->writeString("inputs(");
671 for(i = 0; i < numVariables; i++)
673 PcpVariable* var = scop->getVariable(i);
675 if(var->getIsInput())
677 if(first)
678 first = false;
679 else
680 this->writeString(", ");
682 this->emitVariableUse(var);
685 this->writeString(")");
688 // Write SCOP outputs into context.
689 void
690 PcpEmitter::emitScopOutputs(PcpScop* scop)
692 int numVariables = scop->getNumVariables();
693 bool first = true;
694 int i;
696 this->writeString("outputs(");
698 for(i = 0; i < numVariables; i++)
700 PcpVariable* var = scop->getVariable(i);
702 if(var->getIsOutput())
704 if(first)
705 first = false;
706 else
707 this->writeString(", ");
710 this->emitVariableUse(var);
714 this->writeString(")");
718 // Write SCOP parameters.
719 void
720 PcpEmitter::emitScopParameters(PcpScop* scop)
722 int i;
723 int numParameters = scop->getNumParameters();
724 bool first = true;
726 this->writeString("parameters(");
728 // Write parameters.
729 for(i = 0; i < numParameters; i++)
731 if(first)
732 first = false;
733 else
734 this->writeString(", ");
736 this->emitParameterUse(scop->getParameter(i));
739 this->writeString(")");
743 // Write SCOP parameter declarations.
744 void
745 PcpEmitter::emitScopParametersDecl(PcpScop* scop)
747 int i;
748 int numParameters = scop->getNumParameters();
750 // Write parameter declarations.
751 for(i = 0; i < numParameters; i++)
753 this->emitParameterDecl(scop->getParameter(i));
754 this->writeNewline();
758 // Write SCOP variable declarations.
759 void
760 PcpEmitter::emitScopVariables(PcpScop* scop)
762 int i;
763 int numVariables = scop->getNumVariables();
765 // Write variable declarations.
766 for(i = 0; i < numVariables; i++)
768 this->emitVariableDecl(scop->getVariable(i));
769 this->writeNewline();
773 void
774 PcpEmitter::emitTypeDefs(PcpScop* scop)
776 int i;
777 int numVariables = scop->getNumVariables();
778 PcpSet<PcpArrayType*>* emittedTypes = new PcpSet<PcpArrayType*>();
780 for(i = 0; i < numVariables; i++)
782 PcpVariable* variable = scop->getVariable(i);
783 PcpArrayType* type = variable->getType();
784 if(!emittedTypes->contains(type) &&
785 type->getName() != NULL)
787 emittedTypes->insert(type);
788 this->emitObjectNameBindingIndent(type);
789 this->emitArrayTypeDef(type);
790 this->writeNewline();
795 // Write SCOP.
796 void
797 PcpEmitter::emitScop(PcpScop* scop)
799 this->emitScopParametersDecl(scop);
800 this->emitTypeDefs(scop);
801 this->emitScopVariables(scop);
802 this->emitObjectNameBindingIndent(scop);
803 this->writeStringIndent("scop(");
804 this->emitScopInputs(scop);
805 this->writeString(", ");
806 this->emitScopOutputs(scop);
807 this->writeString(", ");
808 this->emitScopParameters(scop);
809 this->emitObjectAnnots(scop);
810 this->writeString(")");
811 this->writeNewline();
812 this->writeStringIndent("{");
814 this->increment();
815 this->writeNewline();
816 this->emitStmt(scop->getBody());
817 this->writeNewline();
818 this->decrement();
820 this->writeStringIndent("}");
821 this->writeNewline();
824 // Convert ANNOT to string.
826 const char*
827 PcpEmitter::pcpAnnotToString(PcpAnnot* annot)
829 PcpEmitter* emitter = new PcpEmitter();
830 emitter->emitAnnot(annot);
831 return emitter->bufferToString();
834 // Convert ANNOTInt to string.
835 const char*
836 PcpEmitter::pcpAnnotIntToString(PcpAnnotInt* annotInt)
838 PcpEmitter* emitter = new PcpEmitter();
839 emitter->emitAnnotInt(annotInt);
840 return emitter->bufferToString();
843 // Convert ANNOTString to string.
844 const char*
845 PcpEmitter::pcpAnnotStringToString(PcpAnnotString* annotString)
847 PcpEmitter* emitter = new PcpEmitter();
848 emitter->emitAnnotString(annotString);
849 return emitter->bufferToString();
852 // Convert ANNOTObject to string.
853 const char*
854 PcpEmitter::pcpAnnotObjectToString(PcpAnnotObject* annotObject)
856 PcpEmitter* emitter = new PcpEmitter();
857 emitter->emitAnnotObject(annotObject);
858 return emitter->bufferToString();
861 // Convert ANNOTTerm to string.
862 const char*
863 PcpEmitter::pcpAnnotTermToString(PcpAnnotTerm* annotTerm)
865 PcpEmitter* emitter = new PcpEmitter();
866 emitter->emitAnnotTerm(annotTerm);
867 return emitter->bufferToString();
870 // Convert TYPE to string.
871 const char*
872 PcpEmitter::pcpArrayTypeToString(PcpArrayType* type)
874 PcpEmitter* emitter = new PcpEmitter();
875 emitter->emitArrayTypeDef(type);
876 return emitter->bufferToString();
879 // Convert EXPR to string.
880 const char*
881 PcpEmitter::pcpExprToString(PcpExpr* expr)
883 PcpEmitter* emitter = new PcpEmitter();
884 emitter->emitExpr(expr);
885 return emitter->bufferToString();
888 // Convert BOOLEXPR to string.
889 const char*
890 PcpEmitter::pcpBoolExprToString(PcpBoolExpr* boolExpr)
892 PcpEmitter* emitter = new PcpEmitter();
893 emitter->emitBoolExpr(boolExpr);
894 return emitter->bufferToString();
897 const char*
898 PcpEmitter::pcpCompareToString(PcpCompare* compare)
900 PcpEmitter* emitter = new PcpEmitter();
901 emitter->emitCompare(compare);
902 return emitter->bufferToString();
906 const char*
907 PcpEmitter::pcpBoolArithToString(PcpBoolArith* boolArith)
909 PcpEmitter* emitter = new PcpEmitter();
910 emitter->emitBoolArith(boolArith);
911 return emitter->bufferToString();
914 // Convert CONSTANT to declaration string.
915 const char*
916 PcpEmitter::pcpConstantToDeclString(PcpConstant* constant)
918 PcpEmitter* emitter = new PcpEmitter();
919 emitter->emitConstantDecl(constant);
920 return emitter->bufferToString();
923 // Convert CONSTANT to use string.
924 const char*
925 PcpEmitter::pcpConstantToUseString(PcpConstant* constant)
927 PcpEmitter* emitter = new PcpEmitter();
928 emitter->emitConstantUse(constant);
929 return emitter->bufferToString();
932 // Convert IV to declaration string.
933 const char*
934 PcpEmitter::pcpIvToDeclString(PcpIv* iv)
936 PcpEmitter* emitter = new PcpEmitter();
937 emitter->emitIvDecl(iv);
938 return emitter->bufferToString();
941 // Convert IV to use string.
942 const char*
943 PcpEmitter::pcpIvToUseString(PcpIv* iv)
945 PcpEmitter* emitter = new PcpEmitter();
946 emitter->emitIvUse(iv);
947 return emitter->bufferToString();
950 // Convert VAR to declaration string.
951 const char*
952 PcpEmitter::pcpVariableToDeclString(PcpVariable* var)
954 PcpEmitter* emitter = new PcpEmitter();
955 emitter->emitVariableDecl(var);
956 return emitter->bufferToString();
959 // Convert VAR to use string.
960 const char*
961 PcpEmitter::pcpVariableToUseString(PcpVariable* var)
963 PcpEmitter* emitter = new PcpEmitter();
964 emitter->emitVariableUse(var);
965 return emitter->bufferToString();
968 // Convert PARAMETER to declaration string.
969 const char*
970 PcpEmitter::pcpParameterToDeclString(PcpParameter* parameter)
972 PcpEmitter* emitter = new PcpEmitter();
973 emitter->emitParameterDecl(parameter);
974 return emitter->bufferToString();
977 // Convert PARAMETER to use string.
978 const char*
979 PcpEmitter::pcpParameterToUseString(PcpParameter* parameter)
981 PcpEmitter* emitter = new PcpEmitter();
982 emitter->emitParameterUse(parameter);
983 return emitter->bufferToString();
986 const char*
987 PcpEmitter::pcpArithToString(PcpArith* arith)
989 PcpEmitter* emitter = new PcpEmitter();
990 emitter->emitArith(arith);
991 return emitter->bufferToString();
995 // Convert ACCESS to string.
996 const char*
997 PcpEmitter::pcpArrayAccessToString(PcpArrayAccess* access)
999 PcpEmitter* emitter = new PcpEmitter();
1000 emitter->emitArrayAccess(access);
1001 return emitter->bufferToString();
1004 // Convert COPY to string.
1005 const char*
1006 PcpEmitter::pcpCopyToString(PcpCopy* copy)
1008 PcpEmitter* emitter = new PcpEmitter();
1009 emitter->emitCopy(copy);
1010 return emitter->bufferToString();
1013 // Convert USERStmt to string.
1014 const char*
1015 PcpEmitter::pcpUserStmtToString(PcpUserStmt* userStmt)
1017 PcpEmitter* emitter = new PcpEmitter();
1018 emitter->emitUserStmt(userStmt);
1019 return emitter->bufferToString();
1022 // Convert SEQUENCE to string.
1023 const char*
1024 PcpEmitter::pcpSequenceToString(PcpSequence* sequence)
1026 PcpEmitter* emitter = new PcpEmitter();
1027 emitter->emitSequence(sequence);
1028 return emitter->bufferToString();
1032 // Convert STMT to string.
1033 const char*
1034 PcpEmitter::pcpStmtToString(PcpStmt* stmt)
1036 PcpEmitter* emitter = new PcpEmitter();
1037 emitter->emitStmt(stmt);
1038 return emitter->bufferToString();
1041 // Convert GUARD to string.
1042 const char*
1043 PcpEmitter::pcpGuardToString(PcpGuard* guard)
1045 PcpEmitter* emitter = new PcpEmitter();
1046 emitter->emitGuard(guard);
1047 return emitter->bufferToString();
1050 // Convert LOOP to string.
1051 const char*
1052 PcpEmitter::pcpLoopToString(PcpLoop* loop)
1054 PcpEmitter* emitter = new PcpEmitter();
1055 emitter->emitLoop(loop);
1056 return emitter->bufferToString();
1059 // Convert SCOP into string.
1060 const char*
1061 PcpEmitter::pcpScopToString(PcpScop* scop)
1063 PcpEmitter* emitter = new PcpEmitter();
1064 emitter->getTagFilterSet()->insert("lineinfo");
1065 emitter->emitScop(scop);
1066 return emitter->bufferToString();
1069 PcpEmitter::PcpEmitter()
1071 this->setIndent(0);
1072 this->setStringBuffer(new PcpStringBuffer());
1073 this->setTagFilterSet(new PcpSet<const char*>());