xref: /dflybsd-src/sys/contrib/dev/acpica/source/compiler/aslcompile.c (revision 8711651202bb750eb3b64529c2e2f10dee79cd55)
1 /******************************************************************************
2  *
3  * Module Name: aslcompile - top level compile module
4  *
5  *****************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2014, Intel Corp.
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions, and the following disclaimer,
16  *    without modification.
17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18  *    substantially similar to the "NO WARRANTY" disclaimer below
19  *    ("Disclaimer") and any redistribution must be conditioned upon
20  *    including a substantially similar Disclaimer requirement for further
21  *    binary redistribution.
22  * 3. Neither the names of the above-listed copyright holders nor the names
23  *    of any contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * Alternatively, this software may be distributed under the terms of the
27  * GNU General Public License ("GPL") version 2 as published by the Free
28  * Software Foundation.
29  *
30  * NO WARRANTY
31  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41  * POSSIBILITY OF SUCH DAMAGES.
42  */
43 
44 #include "aslcompiler.h"
45 #include "dtcompiler.h"
46 #include "acnamesp.h"
47 
48 #include <stdio.h>
49 #include <time.h>
50 #include <acapps.h>
51 
52 #define _COMPONENT          ACPI_COMPILER
53         ACPI_MODULE_NAME    ("aslcompile")
54 
55 /*
56  * Main parser entry
57  * External is here in case the parser emits the same external in the
58  * generated header. (Newer versions of Bison)
59  */
60 int
61 AslCompilerparse(
62     void);
63 
64 /* Local prototypes */
65 
66 static void
67 CmFlushSourceCode (
68     void);
69 
70 static void
71 CmDumpAllEvents (
72     void);
73 
74 
75 /*******************************************************************************
76  *
77  * FUNCTION:    CmDoCompile
78  *
79  * PARAMETERS:  None
80  *
81  * RETURN:      Status (0 = OK)
82  *
83  * DESCRIPTION: This procedure performs the entire compile
84  *
85  ******************************************************************************/
86 
87 int
88 CmDoCompile (
89     void)
90 {
91     ACPI_STATUS             Status;
92     UINT8                   FullCompile;
93     UINT8                   Event;
94 
95 
96     FullCompile = UtBeginEvent ("*** Total Compile time ***");
97     Event = UtBeginEvent ("Open input and output files");
98     UtEndEvent (Event);
99 
100     Event = UtBeginEvent ("Preprocess input file");
101     if (Gbl_PreprocessFlag)
102     {
103         /* Preprocessor */
104 
105         PrDoPreprocess ();
106         if (Gbl_PreprocessOnly)
107         {
108             UtEndEvent (Event);
109             CmCleanupAndExit ();
110             return (0);
111         }
112     }
113     UtEndEvent (Event);
114 
115     /* Build the parse tree */
116 
117     Event = UtBeginEvent ("Parse source code and build parse tree");
118     AslCompilerparse();
119     UtEndEvent (Event);
120 
121     /* Check for parse errors */
122 
123     Status = AslCheckForErrorExit ();
124     if (ACPI_FAILURE (Status))
125     {
126         fprintf (stderr, "Compiler aborting due to parser-detected syntax error(s)\n");
127         LsDumpParseTree ();
128         goto ErrorExit;
129     }
130 
131     /* Did the parse tree get successfully constructed? */
132 
133     if (!RootNode)
134     {
135         /*
136          * If there are no errors, then we have some sort of
137          * internal problem.
138          */
139         AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL,
140             NULL, "- Could not resolve parse tree root node");
141 
142         goto ErrorExit;
143     }
144 
145     /* Flush out any remaining source after parse tree is complete */
146 
147     Event = UtBeginEvent ("Flush source input");
148     CmFlushSourceCode ();
149 
150     /* Optional parse tree dump, compiler debug output only */
151 
152     LsDumpParseTree ();
153 
154     OpcGetIntegerWidth (RootNode);
155     UtEndEvent (Event);
156 
157     /* Pre-process parse tree for any operator transforms */
158 
159     Event = UtBeginEvent ("Parse tree transforms");
160     DbgPrint (ASL_DEBUG_OUTPUT, "\nParse tree transforms\n\n");
161     TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD,
162         TrAmlTransformWalk, NULL, NULL);
163     UtEndEvent (Event);
164 
165     /* Generate AML opcodes corresponding to the parse tokens */
166 
167     Event = UtBeginEvent ("Generate AML opcodes");
168     DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating AML opcodes\n\n");
169     TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL,
170         OpcAmlOpcodeWalk, NULL);
171     UtEndEvent (Event);
172 
173     /*
174      * Now that the input is parsed, we can open the AML output file.
175      * Note: by default, the name of this file comes from the table descriptor
176      * within the input file.
177      */
178     Event = UtBeginEvent ("Open AML output file");
179     Status = FlOpenAmlOutputFile (Gbl_OutputFilenamePrefix);
180     UtEndEvent (Event);
181     if (ACPI_FAILURE (Status))
182     {
183         AePrintErrorLog (ASL_FILE_STDERR);
184         return (-1);
185     }
186 
187     /* Interpret and generate all compile-time constants */
188 
189     Event = UtBeginEvent ("Constant folding via AML interpreter");
190     DbgPrint (ASL_DEBUG_OUTPUT,
191         "\nInterpreting compile-time constant expressions\n\n");
192     TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD,
193         OpcAmlConstantWalk, NULL, NULL);
194     UtEndEvent (Event);
195 
196     /* Update AML opcodes if necessary, after constant folding */
197 
198     Event = UtBeginEvent ("Updating AML opcodes after constant folding");
199     DbgPrint (ASL_DEBUG_OUTPUT,
200         "\nUpdating AML opcodes after constant folding\n\n");
201     TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD,
202         NULL, OpcAmlOpcodeUpdateWalk, NULL);
203     UtEndEvent (Event);
204 
205     /* Calculate all AML package lengths */
206 
207     Event = UtBeginEvent ("Generate AML package lengths");
208     DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating Package lengths\n\n");
209     TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL,
210         LnPackageLengthWalk, NULL);
211     UtEndEvent (Event);
212 
213     if (Gbl_ParseOnlyFlag)
214     {
215         AePrintErrorLog (ASL_FILE_STDERR);
216         UtDisplaySummary (ASL_FILE_STDERR);
217         if (Gbl_DebugFlag)
218         {
219             /* Print error summary to the stdout also */
220 
221             AePrintErrorLog (ASL_FILE_STDOUT);
222             UtDisplaySummary (ASL_FILE_STDOUT);
223         }
224         UtEndEvent (FullCompile);
225         return (0);
226     }
227 
228     /*
229      * Create an internal namespace and use it as a symbol table
230      */
231 
232     /* Namespace loading */
233 
234     Event = UtBeginEvent ("Create ACPI Namespace");
235     Status = LdLoadNamespace (RootNode);
236     UtEndEvent (Event);
237     if (ACPI_FAILURE (Status))
238     {
239         goto ErrorExit;
240     }
241 
242     /* Namespace cross-reference */
243 
244     AslGbl_NamespaceEvent = UtBeginEvent ("Cross reference parse tree and Namespace");
245     Status = XfCrossReferenceNamespace ();
246     if (ACPI_FAILURE (Status))
247     {
248         goto ErrorExit;
249     }
250 
251     /* Namespace - Check for non-referenced objects */
252 
253     LkFindUnreferencedObjects ();
254     UtEndEvent (AslGbl_NamespaceEvent);
255 
256     /*
257      * Semantic analysis. This can happen only after the
258      * namespace has been loaded and cross-referenced.
259      *
260      * part one - check control methods
261      */
262     Event = UtBeginEvent ("Analyze control method return types");
263     AnalysisWalkInfo.MethodStack = NULL;
264 
265     DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Method analysis\n\n");
266     TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE,
267         MtMethodAnalysisWalkBegin,
268         MtMethodAnalysisWalkEnd, &AnalysisWalkInfo);
269     UtEndEvent (Event);
270 
271     /* Semantic error checking part two - typing of method returns */
272 
273     Event = UtBeginEvent ("Determine object types returned by methods");
274     DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Method typing\n\n");
275     TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD,
276         NULL, AnMethodTypingWalkEnd, NULL);
277     UtEndEvent (Event);
278 
279     /* Semantic error checking part three - operand type checking */
280 
281     Event = UtBeginEvent ("Analyze AML operand types");
282     DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Operand type checking\n\n");
283     TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD,
284         NULL, AnOperandTypecheckWalkEnd, &AnalysisWalkInfo);
285     UtEndEvent (Event);
286 
287     /* Semantic error checking part four - other miscellaneous checks */
288 
289     Event = UtBeginEvent ("Miscellaneous analysis");
290     DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - miscellaneous\n\n");
291     TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD,
292         AnOtherSemanticAnalysisWalkBegin,
293         NULL, &AnalysisWalkInfo);
294     UtEndEvent (Event);
295 
296     /* Calculate all AML package lengths */
297 
298     Event = UtBeginEvent ("Finish AML package length generation");
299     DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating Package lengths\n\n");
300     TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL,
301         LnInitLengthsWalk, NULL);
302     TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL,
303         LnPackageLengthWalk, NULL);
304     UtEndEvent (Event);
305 
306     /* Code generation - emit the AML */
307 
308     Event = UtBeginEvent ("Generate AML code and write output files");
309     CgGenerateAmlOutput ();
310     UtEndEvent (Event);
311 
312     Event = UtBeginEvent ("Write optional output files");
313     CmDoOutputFiles ();
314     UtEndEvent (Event);
315 
316     UtEndEvent (FullCompile);
317     CmCleanupAndExit ();
318     return (0);
319 
320 ErrorExit:
321     UtEndEvent (FullCompile);
322     CmCleanupAndExit ();
323     return (-1);
324 }
325 
326 
327 /*******************************************************************************
328  *
329  * FUNCTION:    AslCompilerSignon
330  *
331  * PARAMETERS:  FileId      - ID of the output file
332  *
333  * RETURN:      None
334  *
335  * DESCRIPTION: Display compiler signon
336  *
337  ******************************************************************************/
338 
339 void
340 AslCompilerSignon (
341     UINT32                  FileId)
342 {
343     char                    *Prefix = "";
344     char                    *UtilityName;
345 
346 
347     /* Set line prefix depending on the destination file type */
348 
349     switch (FileId)
350     {
351     case ASL_FILE_ASM_SOURCE_OUTPUT:
352     case ASL_FILE_ASM_INCLUDE_OUTPUT:
353 
354         Prefix = "; ";
355         break;
356 
357     case ASL_FILE_HEX_OUTPUT:
358 
359         if (Gbl_HexOutputFlag == HEX_OUTPUT_ASM)
360         {
361             Prefix = "; ";
362         }
363         else if ((Gbl_HexOutputFlag == HEX_OUTPUT_C) ||
364                  (Gbl_HexOutputFlag == HEX_OUTPUT_ASL))
365         {
366             FlPrintFile (ASL_FILE_HEX_OUTPUT, "/*\n");
367             Prefix = " * ";
368         }
369         break;
370 
371     case ASL_FILE_C_SOURCE_OUTPUT:
372     case ASL_FILE_C_OFFSET_OUTPUT:
373     case ASL_FILE_C_INCLUDE_OUTPUT:
374 
375         Prefix = " * ";
376         break;
377 
378     default:
379 
380         /* No other output types supported */
381 
382         break;
383     }
384 
385     /* Running compiler or disassembler? */
386 
387     if (Gbl_DisasmFlag)
388     {
389         UtilityName = AML_DISASSEMBLER_NAME;
390     }
391     else
392     {
393         UtilityName = ASL_COMPILER_NAME;
394     }
395 
396     /* Compiler signon with copyright */
397 
398     FlPrintFile (FileId, "%s\n", Prefix);
399     FlPrintFile (FileId, ACPI_COMMON_HEADER (UtilityName, Prefix));
400 }
401 
402 
403 /*******************************************************************************
404  *
405  * FUNCTION:    AslCompilerFileHeader
406  *
407  * PARAMETERS:  FileId      - ID of the output file
408  *
409  * RETURN:      None
410  *
411  * DESCRIPTION: Header used at the beginning of output files
412  *
413  ******************************************************************************/
414 
415 void
416 AslCompilerFileHeader (
417     UINT32                  FileId)
418 {
419     struct tm               *NewTime;
420     time_t                  Aclock;
421     char                    *Prefix = "";
422 
423 
424     /* Set line prefix depending on the destination file type */
425 
426     switch (FileId)
427     {
428     case ASL_FILE_ASM_SOURCE_OUTPUT:
429     case ASL_FILE_ASM_INCLUDE_OUTPUT:
430 
431         Prefix = "; ";
432         break;
433 
434     case ASL_FILE_HEX_OUTPUT:
435 
436         if (Gbl_HexOutputFlag == HEX_OUTPUT_ASM)
437         {
438             Prefix = "; ";
439         }
440         else if ((Gbl_HexOutputFlag == HEX_OUTPUT_C) ||
441                  (Gbl_HexOutputFlag == HEX_OUTPUT_ASL))
442         {
443             Prefix = " * ";
444         }
445         break;
446 
447     case ASL_FILE_C_SOURCE_OUTPUT:
448     case ASL_FILE_C_OFFSET_OUTPUT:
449     case ASL_FILE_C_INCLUDE_OUTPUT:
450 
451         Prefix = " * ";
452         break;
453 
454     default:
455 
456         /* No other output types supported */
457 
458         break;
459     }
460 
461     /* Compilation header with timestamp */
462 
463     (void) time (&Aclock);
464     NewTime = localtime (&Aclock);
465 
466     FlPrintFile (FileId,
467         "%sCompilation of \"%s\" - %s%s\n",
468         Prefix, Gbl_Files[ASL_FILE_INPUT].Filename, asctime (NewTime),
469         Prefix);
470 
471     switch (FileId)
472     {
473     case ASL_FILE_C_SOURCE_OUTPUT:
474     case ASL_FILE_C_OFFSET_OUTPUT:
475     case ASL_FILE_C_INCLUDE_OUTPUT:
476 
477         FlPrintFile (FileId, " */\n");
478         break;
479 
480     default:
481 
482         /* Nothing to do for other output types */
483 
484         break;
485     }
486 }
487 
488 
489 /*******************************************************************************
490  *
491  * FUNCTION:    CmFlushSourceCode
492  *
493  * PARAMETERS:  None
494  *
495  * RETURN:      None
496  *
497  * DESCRIPTION: Read in any remaining source code after the parse tree
498  *              has been constructed.
499  *
500  ******************************************************************************/
501 
502 static void
503 CmFlushSourceCode (
504     void)
505 {
506     char                    Buffer;
507 
508 
509     while (FlReadFile (ASL_FILE_INPUT, &Buffer, 1) != AE_ERROR)
510     {
511         AslInsertLineBuffer ((int) Buffer);
512     }
513 
514     AslResetCurrentLineBuffer ();
515 }
516 
517 
518 /*******************************************************************************
519  *
520  * FUNCTION:    CmDoOutputFiles
521  *
522  * PARAMETERS:  None
523  *
524  * RETURN:      None.
525  *
526  * DESCRIPTION: Create all "listing" type files
527  *
528  ******************************************************************************/
529 
530 void
531 CmDoOutputFiles (
532     void)
533 {
534 
535     /* Create listings and hex files */
536 
537     LsDoListings ();
538     HxDoHexOutput ();
539 
540     /* Dump the namespace to the .nsp file if requested */
541 
542     (void) NsDisplayNamespace ();
543 }
544 
545 
546 /*******************************************************************************
547  *
548  * FUNCTION:    CmDumpAllEvents
549  *
550  * PARAMETERS:  None
551  *
552  * RETURN:      None.
553  *
554  * DESCRIPTION: Dump all compiler events
555  *
556  ******************************************************************************/
557 
558 static void
559 CmDumpAllEvents (
560     void)
561 {
562     ASL_EVENT_INFO          *Event;
563     UINT32                  Delta;
564     UINT32                  USec;
565     UINT32                  MSec;
566     UINT32                  i;
567 
568 
569     Event = AslGbl_Events;
570 
571     DbgPrint (ASL_DEBUG_OUTPUT, "\n\nElapsed time for major events\n\n");
572     if (Gbl_CompileTimesFlag)
573     {
574         printf ("\nElapsed time for major events\n\n");
575     }
576 
577     for (i = 0; i < AslGbl_NextEvent; i++)
578     {
579         if (Event->Valid)
580         {
581             /* Delta will be in 100-nanosecond units */
582 
583             Delta = (UINT32) (Event->EndTime - Event->StartTime);
584 
585             USec = Delta / ACPI_100NSEC_PER_USEC;
586             MSec = Delta / ACPI_100NSEC_PER_MSEC;
587 
588             /* Round milliseconds up */
589 
590             if ((USec - (MSec * ACPI_USEC_PER_MSEC)) >= 500)
591             {
592                 MSec++;
593             }
594 
595             DbgPrint (ASL_DEBUG_OUTPUT, "%8u usec %8u msec - %s\n",
596                 USec, MSec, Event->EventName);
597 
598             if (Gbl_CompileTimesFlag)
599             {
600                 printf ("%8u usec %8u msec - %s\n",
601                     USec, MSec, Event->EventName);
602             }
603         }
604 
605         Event++;
606     }
607 }
608 
609 
610 /*******************************************************************************
611  *
612  * FUNCTION:    CmCleanupAndExit
613  *
614  * PARAMETERS:  None
615  *
616  * RETURN:      None.
617  *
618  * DESCRIPTION: Close all open files and exit the compiler
619  *
620  ******************************************************************************/
621 
622 void
623 CmCleanupAndExit (
624     void)
625 {
626     UINT32                  i;
627     BOOLEAN                 DeleteAmlFile = FALSE;
628 
629 
630     AePrintErrorLog (ASL_FILE_STDERR);
631     if (Gbl_DebugFlag)
632     {
633         /* Print error summary to stdout also */
634 
635         AePrintErrorLog (ASL_FILE_STDOUT);
636     }
637 
638     /* Emit compile times if enabled */
639 
640     CmDumpAllEvents ();
641 
642     if (Gbl_CompileTimesFlag)
643     {
644         printf ("\nMiscellaneous compile statistics\n\n");
645         printf ("%11u : %s\n", TotalParseNodes, "Parse nodes");
646         printf ("%11u : %s\n", Gbl_NsLookupCount, "Namespace searches");
647         printf ("%11u : %s\n", TotalNamedObjects, "Named objects");
648         printf ("%11u : %s\n", TotalMethods, "Control methods");
649         printf ("%11u : %s\n", TotalAllocations, "Memory Allocations");
650         printf ("%11u : %s\n", TotalAllocated, "Total allocated memory");
651         printf ("%11u : %s\n", TotalFolds, "Constant subtrees folded");
652         printf ("\n");
653     }
654 
655     if (Gbl_NsLookupCount)
656     {
657         DbgPrint (ASL_DEBUG_OUTPUT,
658             "\n\nMiscellaneous compile statistics\n\n");
659 
660         DbgPrint (ASL_DEBUG_OUTPUT,
661             "%32s : %u\n", "Total Namespace searches",
662             Gbl_NsLookupCount);
663 
664         DbgPrint (ASL_DEBUG_OUTPUT,
665             "%32s : %u usec\n", "Time per search", ((UINT32)
666             (AslGbl_Events[AslGbl_NamespaceEvent].EndTime -
667                 AslGbl_Events[AslGbl_NamespaceEvent].StartTime) / 10) /
668                 Gbl_NsLookupCount);
669     }
670 
671     if (Gbl_ExceptionCount[ASL_ERROR] > ASL_MAX_ERROR_COUNT)
672     {
673         printf ("\nMaximum error count (%u) exceeded\n",
674             ASL_MAX_ERROR_COUNT);
675     }
676 
677     UtDisplaySummary (ASL_FILE_STDOUT);
678 
679     /*
680      * We will delete the AML file if there are errors and the
681      * force AML output option has not been used.
682      */
683     if ((Gbl_ExceptionCount[ASL_ERROR] > 0) &&
684         (!Gbl_IgnoreErrors) &&
685         Gbl_Files[ASL_FILE_AML_OUTPUT].Handle)
686     {
687         DeleteAmlFile = TRUE;
688     }
689 
690     /* Close all open files */
691 
692     /*
693      * Take care with the preprocessor file (.i), it might be the same
694      * as the "input" file, depending on where the compiler has terminated
695      * or aborted. Prevent attempt to close the same file twice in
696      * loop below.
697      */
698     if (Gbl_Files[ASL_FILE_PREPROCESSOR].Handle ==
699         Gbl_Files[ASL_FILE_INPUT].Handle)
700     {
701         Gbl_Files[ASL_FILE_PREPROCESSOR].Handle = NULL;
702     }
703 
704     /* Close the standard I/O files */
705 
706     for (i = ASL_FILE_INPUT; i < ASL_MAX_FILE_TYPE; i++)
707     {
708         FlCloseFile (i);
709     }
710 
711     /* Delete AML file if there are errors */
712 
713     if (DeleteAmlFile)
714     {
715         FlDeleteFile (ASL_FILE_AML_OUTPUT);
716     }
717 
718     /* Delete the preprocessor output file (.i) unless -li flag is set */
719 
720     if (!Gbl_PreprocessorOutputFlag &&
721         Gbl_PreprocessFlag)
722     {
723         FlDeleteFile (ASL_FILE_PREPROCESSOR);
724     }
725 
726     /*
727      * Delete intermediate ("combined") source file (if -ls flag not set)
728      * This file is created during normal ASL/AML compiles. It is not
729      * created by the data table compiler.
730      *
731      * If the -ls flag is set, then the .SRC file should not be deleted.
732      * In this case, Gbl_SourceOutputFlag is set to TRUE.
733      *
734      * Note: Handles are cleared by FlCloseFile above, so we look at the
735      * filename instead, to determine if the .SRC file was actually
736      * created.
737      *
738      * TBD: SourceOutput should be .TMP, then rename if we want to keep it?
739      */
740     if (!Gbl_SourceOutputFlag)
741     {
742         FlDeleteFile (ASL_FILE_SOURCE_OUTPUT);
743     }
744 
745     /* Final cleanup after compiling one file */
746 
747     CmDeleteCaches ();
748 }
749 
750 
751 /*******************************************************************************
752  *
753  * FUNCTION:    CmDeleteCaches
754  *
755  * PARAMETERS:  None
756  *
757  * RETURN:      None
758  *
759  * DESCRIPTION: Delete all local cache buffer blocks
760  *
761  ******************************************************************************/
762 
763 void
764 CmDeleteCaches (
765     void)
766 {
767     UINT32                  BufferCount;
768     ASL_CACHE_INFO          *Next;
769 
770 
771     /* Parse Op cache */
772 
773     BufferCount = 0;
774     while (Gbl_ParseOpCacheList)
775     {
776         Next = Gbl_ParseOpCacheList->Next;
777         ACPI_FREE (Gbl_ParseOpCacheList);
778         Gbl_ParseOpCacheList = Next;
779         BufferCount++;
780     }
781 
782     DbgPrint (ASL_DEBUG_OUTPUT,
783         "%u ParseOps, Buffer size: %u ops (%u bytes), %u Buffers\n",
784         Gbl_ParseOpCount, ASL_PARSEOP_CACHE_SIZE,
785         (sizeof (ACPI_PARSE_OBJECT) * ASL_PARSEOP_CACHE_SIZE), BufferCount);
786 
787     Gbl_ParseOpCount = 0;
788     Gbl_ParseOpCacheNext = NULL;
789     Gbl_ParseOpCacheLast = NULL;
790     RootNode = NULL;
791 
792     /* Generic string cache */
793 
794     BufferCount = 0;
795     while (Gbl_StringCacheList)
796     {
797         Next = Gbl_StringCacheList->Next;
798         ACPI_FREE (Gbl_StringCacheList);
799         Gbl_StringCacheList = Next;
800         BufferCount++;
801     }
802 
803     DbgPrint (ASL_DEBUG_OUTPUT,
804         "%u Strings (%u bytes), Buffer size: %u bytes, %u Buffers\n",
805         Gbl_StringCount, Gbl_StringSize, ASL_STRING_CACHE_SIZE, BufferCount);
806 
807     Gbl_StringSize = 0;
808     Gbl_StringCount = 0;
809     Gbl_StringCacheNext = NULL;
810     Gbl_StringCacheLast = NULL;
811 }
812