summaryrefslogtreecommitdiffstats
path: root/sys/contrib/dev/acpica/compiler/aslcompile.c
diff options
context:
space:
mode:
authorjkim <jkim@FreeBSD.org>2016-09-30 22:40:58 +0000
committerjkim <jkim@FreeBSD.org>2016-09-30 22:40:58 +0000
commitdba8c0a565199df70a86f6a036d00c92f0c7675f (patch)
treecf4924274c6e92898c01efb3c8ba31b34f0630f2 /sys/contrib/dev/acpica/compiler/aslcompile.c
parent0f41551ef9dde560d9d191d7190af02904dbf611 (diff)
downloadFreeBSD-src-dba8c0a565199df70a86f6a036d00c92f0c7675f.zip
FreeBSD-src-dba8c0a565199df70a86f6a036d00c92f0c7675f.tar.gz
MFC: r284583, r285797, r285799, r287168, r298714, r298720, r298838,
r300879 Merge ACPICA up to 20160527. Requested by: mav
Diffstat (limited to 'sys/contrib/dev/acpica/compiler/aslcompile.c')
-rw-r--r--sys/contrib/dev/acpica/compiler/aslcompile.c130
1 files changed, 84 insertions, 46 deletions
diff --git a/sys/contrib/dev/acpica/compiler/aslcompile.c b/sys/contrib/dev/acpica/compiler/aslcompile.c
index 0b0ca7a..3dbd0f6 100644
--- a/sys/contrib/dev/acpica/compiler/aslcompile.c
+++ b/sys/contrib/dev/acpica/compiler/aslcompile.c
@@ -5,7 +5,7 @@
*****************************************************************************/
/*
- * Copyright (C) 2000 - 2015, Intel Corp.
+ * Copyright (C) 2000 - 2016, Intel Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -100,9 +100,16 @@ CmDoCompile (
Event = UtBeginEvent ("Preprocess input file");
if (Gbl_PreprocessFlag)
{
+ /* Enter compiler name as a #define */
+
+ PrAddDefine (ASL_DEFINE, "", FALSE);
+
/* Preprocessor */
PrDoPreprocess ();
+ Gbl_CurrentLineNumber = 1;
+ Gbl_LogicalLineNumber = 1;
+
if (Gbl_PreprocessOnly)
{
UtEndEvent (Event);
@@ -112,6 +119,7 @@ CmDoCompile (
}
UtEndEvent (Event);
+
/* Build the parse tree */
Event = UtBeginEvent ("Parse source code and build parse tree");
@@ -122,14 +130,15 @@ CmDoCompile (
if (Gbl_SyntaxError)
{
- fprintf (stderr, "Compiler aborting due to parser-detected syntax error(s)\n");
+ fprintf (stderr,
+ "Compiler aborting due to parser-detected syntax error(s)\n");
LsDumpParseTree ();
goto ErrorExit;
}
/* Did the parse tree get successfully constructed? */
- if (!RootNode)
+ if (!Gbl_ParseTreeRoot)
{
/*
* If there are no errors, then we have some sort of
@@ -157,29 +166,29 @@ CmDoCompile (
LsDumpParseTree ();
- OpcGetIntegerWidth (RootNode);
+ OpcGetIntegerWidth (Gbl_ParseTreeRoot->Asl.Child);
UtEndEvent (Event);
/* Pre-process parse tree for any operator transforms */
Event = UtBeginEvent ("Parse tree transforms");
DbgPrint (ASL_DEBUG_OUTPUT, "\nParse tree transforms\n\n");
- TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD,
- TrAmlTransformWalk, NULL, NULL);
+ TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_TWICE,
+ TrAmlTransformWalkBegin, TrAmlTransformWalkEnd, NULL);
UtEndEvent (Event);
/* Generate AML opcodes corresponding to the parse tokens */
Event = UtBeginEvent ("Generate AML opcodes");
- DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating AML opcodes\n\n");
- TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL,
+ DbgPrint (ASL_DEBUG_OUTPUT, "Generating AML opcodes\n\n");
+ TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD, NULL,
OpcAmlOpcodeWalk, NULL);
UtEndEvent (Event);
/*
* Now that the input is parsed, we can open the AML output file.
- * Note: by default, the name of this file comes from the table descriptor
- * within the input file.
+ * Note: by default, the name of this file comes from the table
+ * descriptor within the input file.
*/
Event = UtBeginEvent ("Open AML output file");
Status = FlOpenAmlOutputFile (Gbl_OutputFilenamePrefix);
@@ -194,12 +203,12 @@ CmDoCompile (
Event = UtBeginEvent ("Constant folding via AML interpreter");
DbgPrint (ASL_DEBUG_OUTPUT,
- "\nInterpreting compile-time constant expressions\n\n");
+ "Interpreting compile-time constant expressions\n\n");
if (Gbl_FoldConstants)
{
- TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD,
- OpcAmlConstantWalk, NULL, NULL);
+ TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD,
+ NULL, OpcAmlConstantWalk, NULL);
}
else
{
@@ -211,16 +220,16 @@ CmDoCompile (
Event = UtBeginEvent ("Updating AML opcodes after constant folding");
DbgPrint (ASL_DEBUG_OUTPUT,
- "\nUpdating AML opcodes after constant folding\n\n");
- TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD,
+ "Updating AML opcodes after constant folding\n\n");
+ TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD,
NULL, OpcAmlOpcodeUpdateWalk, NULL);
UtEndEvent (Event);
/* Calculate all AML package lengths */
Event = UtBeginEvent ("Generate AML package lengths");
- DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating Package lengths\n\n");
- TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL,
+ DbgPrint (ASL_DEBUG_OUTPUT, "Generating Package lengths\n\n");
+ TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD, NULL,
LnPackageLengthWalk, NULL);
UtEndEvent (Event);
@@ -246,7 +255,8 @@ CmDoCompile (
/* Namespace loading */
Event = UtBeginEvent ("Create ACPI Namespace");
- Status = LdLoadNamespace (RootNode);
+ DbgPrint (ASL_DEBUG_OUTPUT, "Creating ACPI Namespace\n\n");
+ Status = LdLoadNamespace (Gbl_ParseTreeRoot);
UtEndEvent (Event);
if (ACPI_FAILURE (Status))
{
@@ -255,7 +265,9 @@ CmDoCompile (
/* Namespace cross-reference */
- AslGbl_NamespaceEvent = UtBeginEvent ("Cross reference parse tree and Namespace");
+ AslGbl_NamespaceEvent = UtBeginEvent (
+ "Cross reference parse tree and Namespace");
+ DbgPrint (ASL_DEBUG_OUTPUT, "Cross referencing namespace\n\n");
Status = XfCrossReferenceNamespace ();
if (ACPI_FAILURE (Status))
{
@@ -267,6 +279,17 @@ CmDoCompile (
LkFindUnreferencedObjects ();
UtEndEvent (AslGbl_NamespaceEvent);
+ /* Resolve External Declarations */
+
+ if (Gbl_DoExternals)
+ {
+ Event = UtBeginEvent ("Resolve all Externals");
+ DbgPrint (ASL_DEBUG_OUTPUT, "\nResolve Externals\n\n");
+ TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_TWICE,
+ ExAmlExternalWalkBegin, ExAmlExternalWalkEnd, NULL);
+ UtEndEvent (Event);
+ }
+
/*
* Semantic analysis. This can happen only after the
* namespace has been loaded and cross-referenced.
@@ -276,33 +299,50 @@ CmDoCompile (
Event = UtBeginEvent ("Analyze control method return types");
AnalysisWalkInfo.MethodStack = NULL;
- DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Method analysis\n\n");
- TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE,
+ DbgPrint (ASL_DEBUG_OUTPUT, "Semantic analysis - Method analysis\n\n");
+
+ if (Gbl_CrossReferenceOutput)
+ {
+ OtPrintHeaders ("Part 1: Object Reference Map "
+ "(Object references from within each control method)");
+ }
+
+ TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_TWICE,
MtMethodAnalysisWalkBegin,
MtMethodAnalysisWalkEnd, &AnalysisWalkInfo);
UtEndEvent (Event);
+ /* Generate the object cross-reference file if requested */
+
+ Event = UtBeginEvent ("Generate cross-reference file");
+ OtCreateXrefFile ();
+ UtEndEvent (Event);
+
/* Semantic error checking part two - typing of method returns */
Event = UtBeginEvent ("Determine object types returned by methods");
- DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Method typing\n\n");
- TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD,
+ DbgPrint (ASL_DEBUG_OUTPUT, "Semantic analysis - Method typing\n\n");
+ TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD,
NULL, AnMethodTypingWalkEnd, NULL);
UtEndEvent (Event);
/* Semantic error checking part three - operand type checking */
Event = UtBeginEvent ("Analyze AML operand types");
- DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Operand type checking\n\n");
- TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD,
- NULL, AnOperandTypecheckWalkEnd, &AnalysisWalkInfo);
+ DbgPrint (ASL_DEBUG_OUTPUT,
+ "Semantic analysis - Operand type checking\n\n");
+ if (Gbl_DoTypechecking)
+ {
+ TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD,
+ NULL, AnOperandTypecheckWalkEnd, &AnalysisWalkInfo);
+ }
UtEndEvent (Event);
/* Semantic error checking part four - other miscellaneous checks */
Event = UtBeginEvent ("Miscellaneous analysis");
- DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - miscellaneous\n\n");
- TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD,
+ DbgPrint (ASL_DEBUG_OUTPUT, "Semantic analysis - miscellaneous\n\n");
+ TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD,
AnOtherSemanticAnalysisWalkBegin,
NULL, &AnalysisWalkInfo);
UtEndEvent (Event);
@@ -310,16 +350,17 @@ CmDoCompile (
/* Calculate all AML package lengths */
Event = UtBeginEvent ("Finish AML package length generation");
- DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating Package lengths\n\n");
- TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL,
+ DbgPrint (ASL_DEBUG_OUTPUT, "Generating Package lengths\n\n");
+ TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD, NULL,
LnInitLengthsWalk, NULL);
- TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL,
+ TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD, NULL,
LnPackageLengthWalk, NULL);
UtEndEvent (Event);
/* Code generation - emit the AML */
Event = UtBeginEvent ("Generate AML code and write output files");
+ DbgPrint (ASL_DEBUG_OUTPUT, "Writing AML byte code\n\n");
CgGenerateAmlOutput ();
UtEndEvent (Event);
@@ -579,8 +620,8 @@ CmDumpAllEvents (
{
ASL_EVENT_INFO *Event;
UINT32 Delta;
- UINT32 USec;
- UINT32 MSec;
+ UINT32 MicroSeconds;
+ UINT32 MilliSeconds;
UINT32 i;
@@ -600,23 +641,23 @@ CmDumpAllEvents (
Delta = (UINT32) (Event->EndTime - Event->StartTime);
- USec = Delta / ACPI_100NSEC_PER_USEC;
- MSec = Delta / ACPI_100NSEC_PER_MSEC;
+ MicroSeconds = Delta / ACPI_100NSEC_PER_USEC;
+ MilliSeconds = Delta / ACPI_100NSEC_PER_MSEC;
/* Round milliseconds up */
- if ((USec - (MSec * ACPI_USEC_PER_MSEC)) >= 500)
+ if ((MicroSeconds - (MilliSeconds * ACPI_USEC_PER_MSEC)) >= 500)
{
- MSec++;
+ MilliSeconds++;
}
DbgPrint (ASL_DEBUG_OUTPUT, "%8u usec %8u msec - %s\n",
- USec, MSec, Event->EventName);
+ MicroSeconds, MilliSeconds, Event->EventName);
if (Gbl_CompileTimesFlag)
{
printf ("%8u usec %8u msec - %s\n",
- USec, MSec, Event->EventName);
+ MicroSeconds, MilliSeconds, Event->EventName);
}
}
@@ -708,7 +749,7 @@ CmCleanupAndExit (
/* Close all open files */
/*
- * Take care with the preprocessor file (.i), it might be the same
+ * Take care with the preprocessor file (.pre), it might be the same
* as the "input" file, depending on where the compiler has terminated
* or aborted. Prevent attempt to close the same file twice in
* loop below.
@@ -733,10 +774,9 @@ CmCleanupAndExit (
FlDeleteFile (ASL_FILE_AML_OUTPUT);
}
- /* Delete the preprocessor output file (.i) unless -li flag is set */
+ /* Delete the preprocessor temp file unless full debug was specified */
- if (!Gbl_PreprocessorOutputFlag &&
- Gbl_PreprocessFlag)
+ if (Gbl_PreprocessFlag && !Gbl_KeepPreprocessorTempFile)
{
FlDeleteFile (ASL_FILE_PREPROCESSOR);
}
@@ -752,8 +792,6 @@ CmCleanupAndExit (
* Note: Handles are cleared by FlCloseFile above, so we look at the
* filename instead, to determine if the .SRC file was actually
* created.
- *
- * TBD: SourceOutput should be .TMP, then rename if we want to keep it?
*/
if (!Gbl_SourceOutputFlag)
{
@@ -805,7 +843,7 @@ CmDeleteCaches (
Gbl_ParseOpCount = 0;
Gbl_ParseOpCacheNext = NULL;
Gbl_ParseOpCacheLast = NULL;
- RootNode = NULL;
+ Gbl_ParseTreeRoot = NULL;
/* Generic string cache */
OpenPOWER on IntegriCloud