1 /******************************************************************************
3 * Module Name: aslopt- Compiler optimizations
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2015, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
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.
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.
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.
44 #include <contrib/dev/acpica/compiler/aslcompiler.h>
45 #include "aslcompiler.y.h"
47 #include <contrib/dev/acpica/include/acparser.h>
48 #include <contrib/dev/acpica/include/amlcode.h>
49 #include <contrib/dev/acpica/include/acnamesp.h>
52 #define _COMPONENT ACPI_COMPILER
53 ACPI_MODULE_NAME ("aslopt")
56 static UINT32 OptTotal = 0;
58 /* Local prototypes */
62 ACPI_PARSE_OBJECT *Op,
63 ACPI_WALK_STATE *WalkState,
64 ACPI_NAMESPACE_NODE *CurrentNode,
65 ACPI_NAMESPACE_NODE *TargetNode,
66 ACPI_BUFFER *TargetPath,
70 OptBuildShortestPath (
71 ACPI_PARSE_OBJECT *Op,
72 ACPI_WALK_STATE *WalkState,
73 ACPI_NAMESPACE_NODE *CurrentNode,
74 ACPI_NAMESPACE_NODE *TargetNode,
75 ACPI_BUFFER *CurrentPath,
76 ACPI_BUFFER *TargetPath,
77 ACPI_SIZE AmlNameStringLength,
79 char **ReturnNewPath);
82 OptOptimizeNameDeclaration (
83 ACPI_PARSE_OBJECT *Op,
84 ACPI_WALK_STATE *WalkState,
85 ACPI_NAMESPACE_NODE *CurrentNode,
86 ACPI_NAMESPACE_NODE *TargetNode,
91 /*******************************************************************************
93 * FUNCTION: OptSearchToRoot
95 * PARAMETERS: Op - Current parser op
96 * WalkState - Current state
97 * CurrentNode - Where we are in the namespace
98 * TargetNode - Node to which we are referring
99 * TargetPath - External full path to the target node
100 * NewPath - Where the optimized path is returned
104 * DESCRIPTION: Attempt to optimize a reference to a single 4-character ACPI
105 * name utilizing the search-to-root name resolution algorithm
106 * that is used by AML interpreters.
108 ******************************************************************************/
112 ACPI_PARSE_OBJECT *Op,
113 ACPI_WALK_STATE *WalkState,
114 ACPI_NAMESPACE_NODE *CurrentNode,
115 ACPI_NAMESPACE_NODE *TargetNode,
116 ACPI_BUFFER *TargetPath,
119 ACPI_NAMESPACE_NODE *Node;
120 ACPI_GENERIC_STATE ScopeInfo;
125 ACPI_FUNCTION_NAME (OptSearchToRoot);
129 * Check if search-to-root can be utilized. Use the last NameSeg of
130 * the NamePath and 1) See if can be found and 2) If found, make
131 * sure that it is the same node that we want. If there is another
132 * name in the search path before the one we want, the nodes will
133 * not match, and we cannot use this optimization.
135 Path = &(((char *) TargetPath->Pointer)[TargetPath->Length -
137 ScopeInfo.Scope.Node = CurrentNode;
139 /* Lookup the NameSeg using SEARCH_PARENT (search-to-root) */
141 Status = AcpiNsLookup (&ScopeInfo, Path, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
142 ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
144 if (ACPI_FAILURE (Status))
150 * We found the name, but we must check to make sure that the node
151 * matches. Otherwise, there is another identical name in the search
152 * path that precludes the use of this optimization.
154 if (Node != TargetNode)
157 * This means that another object with the same name was found first,
158 * and we cannot use this optimization.
160 return (AE_NOT_FOUND);
163 /* Found the node, we can use this optimization */
165 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
166 "NAMESEG: %-24s", Path));
168 /* We must allocate a new string for the name (TargetPath gets deleted) */
170 *NewPath = UtStringCacheCalloc (ACPI_NAME_SIZE + 1);
171 strcpy (*NewPath, Path);
173 if (strncmp (*NewPath, "_T_", 3))
175 AslError (ASL_OPTIMIZATION, ASL_MSG_SINGLE_NAME_OPTIMIZATION, Op,
183 /*******************************************************************************
185 * FUNCTION: OptBuildShortestPath
187 * PARAMETERS: Op - Current parser op
188 * WalkState - Current state
189 * CurrentNode - Where we are in the namespace
190 * TargetNode - Node to which we are referring
191 * CurrentPath - External full path to the current node
192 * TargetPath - External full path to the target node
193 * AmlNameStringLength - Length of the original namepath
194 * IsDeclaration - TRUE for declaration, FALSE for reference
195 * ReturnNewPath - Where the optimized path is returned
199 * DESCRIPTION: Build an optimal NamePath using carats
201 ******************************************************************************/
204 OptBuildShortestPath (
205 ACPI_PARSE_OBJECT *Op,
206 ACPI_WALK_STATE *WalkState,
207 ACPI_NAMESPACE_NODE *CurrentNode,
208 ACPI_NAMESPACE_NODE *TargetNode,
209 ACPI_BUFFER *CurrentPath,
210 ACPI_BUFFER *TargetPath,
211 ACPI_SIZE AmlNameStringLength,
213 char **ReturnNewPath)
215 UINT32 NumCommonSegments;
216 UINT32 MaxCommonSegments;
221 char *NewPathExternal;
222 ACPI_NAMESPACE_NODE *Node;
223 ACPI_GENERIC_STATE ScopeInfo;
225 BOOLEAN SubPath = FALSE;
228 ACPI_FUNCTION_NAME (OptBuildShortestPath);
231 ScopeInfo.Scope.Node = CurrentNode;
234 * Determine the maximum number of NameSegs that the Target and Current paths
235 * can possibly have in common. (To optimize, we have to have at least 1)
237 * Note: The external NamePath string lengths are always a multiple of 5
238 * (ACPI_NAME_SIZE + separator)
240 MaxCommonSegments = TargetPath->Length / ACPI_PATH_SEGMENT_LENGTH;
241 if (CurrentPath->Length < TargetPath->Length)
243 MaxCommonSegments = CurrentPath->Length / ACPI_PATH_SEGMENT_LENGTH;
247 * Determine how many NameSegs the two paths have in common.
248 * (Starting from the root)
250 for (NumCommonSegments = 0;
251 NumCommonSegments < MaxCommonSegments;
254 /* Compare two single NameSegs */
256 if (!ACPI_COMPARE_NAME (
257 &((char *) TargetPath->Pointer)[
258 (NumCommonSegments * ACPI_PATH_SEGMENT_LENGTH) + 1],
259 &((char *) CurrentPath->Pointer)[
260 (NumCommonSegments * ACPI_PATH_SEGMENT_LENGTH) + 1]))
268 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " COMMON: %u",
271 /* There must be at least 1 common NameSeg in order to optimize */
273 if (NumCommonSegments == 0)
275 return (AE_NOT_FOUND);
278 if (NumCommonSegments == MaxCommonSegments)
280 if (CurrentPath->Length == TargetPath->Length)
282 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " SAME PATH"));
283 return (AE_NOT_FOUND);
287 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " SUBPATH"));
292 /* Determine how many prefix Carats are required */
294 NumCarats = (CurrentPath->Length / ACPI_PATH_SEGMENT_LENGTH) -
298 * Construct a new target string
300 NewPathExternal = ACPI_ALLOCATE_ZEROED (
301 TargetPath->Length + NumCarats + 1);
303 /* Insert the Carats into the Target string */
305 for (i = 0; i < NumCarats; i++)
307 NewPathExternal[i] = AML_PARENT_PREFIX;
311 * Copy only the necessary (optimal) segments from the original
314 Index = (NumCommonSegments * ACPI_PATH_SEGMENT_LENGTH) + 1;
316 /* Special handling for exact subpath in a name declaration */
318 if (IsDeclaration && SubPath && (CurrentPath->Length > TargetPath->Length))
321 * The current path is longer than the target, and the target is a
322 * subpath of the current path. We must include one more NameSeg of
325 Index -= ACPI_PATH_SEGMENT_LENGTH;
327 /* Special handling for Scope() operator */
329 if (Op->Asl.AmlOpcode == AML_SCOPE_OP)
331 NewPathExternal[i] = AML_PARENT_PREFIX;
333 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "(EXTRA ^)"));
337 /* Make sure we haven't gone off the end of the target path */
339 if (Index > TargetPath->Length)
341 Index = TargetPath->Length;
344 strcpy (&NewPathExternal[i], &((char *) TargetPath->Pointer)[Index]);
345 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " %-24s", NewPathExternal));
348 * Internalize the new target string and check it against the original
349 * string to make sure that this is in fact an optimization. If the
350 * original string is already optimal, there is no point in continuing.
352 Status = AcpiNsInternalizeName (NewPathExternal, &NewPath);
353 if (ACPI_FAILURE (Status))
355 AslCoreSubsystemError (Op, Status, "Internalizing new NamePath",
357 ACPI_FREE (NewPathExternal);
361 if (strlen (NewPath) >= AmlNameStringLength)
363 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
364 " NOT SHORTER (New %u old %u)",
365 (UINT32) strlen (NewPath), (UINT32) AmlNameStringLength));
366 ACPI_FREE (NewPathExternal);
367 return (AE_NOT_FOUND);
371 * Check to make sure that the optimization finds the node we are
372 * looking for. This is simply a sanity check on the new
373 * path that has been created.
375 Status = AcpiNsLookup (&ScopeInfo, NewPath,
376 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
377 ACPI_NS_DONT_OPEN_SCOPE, WalkState, &(Node));
378 if (ACPI_SUCCESS (Status))
380 /* Found the namepath, but make sure the node is correct */
382 if (Node == TargetNode)
384 /* The lookup matched the node, accept this optimization */
386 AslError (ASL_OPTIMIZATION, ASL_MSG_NAME_OPTIMIZATION,
387 Op, NewPathExternal);
388 *ReturnNewPath = NewPath;
392 /* Node is not correct, do not use this optimization */
394 Status = AE_NOT_FOUND;
395 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " ***** WRONG NODE"));
396 AslError (ASL_WARNING, ASL_MSG_COMPILER_INTERNAL, Op,
397 "Not using optimized name - found wrong node");
402 /* The lookup failed, we obviously cannot use this optimization */
404 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " ***** NOT FOUND"));
405 AslError (ASL_WARNING, ASL_MSG_COMPILER_INTERNAL, Op,
406 "Not using optimized name - did not find node");
409 ACPI_FREE (NewPathExternal);
414 /*******************************************************************************
416 * FUNCTION: OptOptimizeNameDeclaration
418 * PARAMETERS: Op - Current parser op
419 * WalkState - Current state
420 * CurrentNode - Where we are in the namespace
421 * AmlNameString - Unoptimized namepath
422 * NewPath - Where the optimized path is returned
424 * RETURN: Status. AE_OK If path is optimized
426 * DESCRIPTION: Perform a simple optimization of removing an extraneous
427 * backslash prefix if we are already at the root scope.
429 ******************************************************************************/
432 OptOptimizeNameDeclaration (
433 ACPI_PARSE_OBJECT *Op,
434 ACPI_WALK_STATE *WalkState,
435 ACPI_NAMESPACE_NODE *CurrentNode,
436 ACPI_NAMESPACE_NODE *TargetNode,
441 char *NewPathExternal;
442 ACPI_NAMESPACE_NODE *Node;
445 ACPI_FUNCTION_TRACE (OptOptimizeNameDeclaration);
448 if (((CurrentNode == AcpiGbl_RootNode) ||
449 (Op->Common.Parent->Asl.ParseOpcode == PARSEOP_DEFINITIONBLOCK)) &&
450 (ACPI_IS_ROOT_PREFIX (AmlNameString[0])))
453 * The current scope is the root, and the namepath has a root prefix
454 * that is therefore extraneous. Remove it.
456 *NewPath = &AmlNameString[1];
460 Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, *NewPath,
461 NULL, &NewPathExternal);
462 if (ACPI_FAILURE (Status))
464 AslCoreSubsystemError (Op, Status, "Externalizing NamePath",
470 * Check to make sure that the optimization finds the node we are
471 * looking for. This is simply a sanity check on the new
472 * path that has been created.
474 * We know that we are at the root, so NULL is used for the scope.
476 Status = AcpiNsLookup (NULL, *NewPath,
477 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
478 ACPI_NS_DONT_OPEN_SCOPE, WalkState, &(Node));
479 if (ACPI_SUCCESS (Status))
481 /* Found the namepath, but make sure the node is correct */
483 if (Node == TargetNode)
485 /* The lookup matched the node, accept this optimization */
487 AslError (ASL_OPTIMIZATION, ASL_MSG_NAME_OPTIMIZATION,
488 Op, NewPathExternal);
490 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
491 "AT ROOT: %-24s", NewPathExternal));
495 /* Node is not correct, do not use this optimization */
497 Status = AE_NOT_FOUND;
498 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
499 " ***** WRONG NODE"));
500 AslError (ASL_WARNING, ASL_MSG_COMPILER_INTERNAL, Op,
501 "Not using optimized name - found wrong node");
506 /* The lookup failed, we obviously cannot use this optimization */
508 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
509 " ***** NOT FOUND"));
510 AslError (ASL_WARNING, ASL_MSG_COMPILER_INTERNAL, Op,
511 "Not using optimized name - did not find node");
514 ACPI_FREE (NewPathExternal);
518 /* Could not optimize */
520 return (AE_NOT_FOUND);
524 /*******************************************************************************
526 * FUNCTION: OptOptimizeNamePath
528 * PARAMETERS: Op - Current parser op
529 * Flags - Opcode info flags
530 * WalkState - Current state
531 * AmlNameString - Unoptimized namepath
532 * TargetNode - Node to which AmlNameString refers
534 * RETURN: None. If path is optimized, the Op is updated with new path
536 * DESCRIPTION: Optimize a Named Declaration or Reference to the minimal length.
537 * Must take into account both the current location in the
538 * namespace and the actual reference path.
540 ******************************************************************************/
543 OptOptimizeNamePath (
544 ACPI_PARSE_OBJECT *Op,
546 ACPI_WALK_STATE *WalkState,
548 ACPI_NAMESPACE_NODE *TargetNode)
551 ACPI_BUFFER TargetPath;
552 ACPI_BUFFER CurrentPath;
553 ACPI_SIZE AmlNameStringLength;
554 ACPI_NAMESPACE_NODE *CurrentNode;
555 char *ExternalNameString;
556 char *NewPath = NULL;
557 ACPI_SIZE HowMuchShorter;
558 ACPI_PARSE_OBJECT *NextOp;
561 ACPI_FUNCTION_TRACE (OptOptimizeNamePath);
564 /* This is an optional optimization */
566 if (!Gbl_ReferenceOptimizationFlag)
571 /* Various required items */
573 if (!TargetNode || !WalkState || !AmlNameString || !Op->Common.Parent)
578 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
579 "PATH OPTIMIZE: Line %5d ParentOp [%12.12s] ThisOp [%12.12s] ",
580 Op->Asl.LogicalLineNumber,
581 AcpiPsGetOpcodeName (Op->Common.Parent->Common.AmlOpcode),
582 AcpiPsGetOpcodeName (Op->Common.AmlOpcode)));
584 if (!(Flags & (AML_NAMED | AML_CREATE)))
586 if (Op->Asl.CompileFlags & NODE_IS_NAME_DECLARATION)
588 /* We don't want to fuss with actual name declaration nodes here */
590 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
591 "******* NAME DECLARATION\n"));
597 * The original path must be longer than one NameSeg (4 chars) for there
598 * to be any possibility that it can be optimized to a shorter string
600 AmlNameStringLength = strlen (AmlNameString);
601 if (AmlNameStringLength <= ACPI_NAME_SIZE)
603 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
604 "NAMESEG %4.4s\n", AmlNameString));
609 * We need to obtain the node that represents the current scope -- where
610 * we are right now in the namespace. We will compare this path
611 * against the Namepath, looking for commonality.
613 CurrentNode = AcpiGbl_RootNode;
614 if (WalkState->ScopeInfo)
616 CurrentNode = WalkState->ScopeInfo->Scope.Node;
619 if (Flags & (AML_NAMED | AML_CREATE))
621 /* This is the declaration of a new name */
623 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "NAME\n"));
626 * The node of interest is the parent of this node (the containing
627 * scope). The actual namespace node may be up more than one level
628 * of parse op or it may not exist at all (if we traverse back
631 NextOp = Op->Asl.Parent;
632 while (NextOp && (!NextOp->Asl.Node))
634 NextOp = NextOp->Asl.Parent;
636 if (NextOp && NextOp->Asl.Node)
638 CurrentNode = NextOp->Asl.Node;
642 CurrentNode = AcpiGbl_RootNode;
647 /* This is a reference to an existing named object */
649 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "REFERENCE\n"));
653 * Obtain the full paths to the two nodes that we are interested in
654 * (Target and current namespace location) in external
655 * format -- something we can easily manipulate
657 TargetPath.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
658 Status = AcpiNsHandleToPathname (TargetNode, &TargetPath);
659 if (ACPI_FAILURE (Status))
661 AslCoreSubsystemError (Op, Status, "Getting Target NamePath",
665 TargetPath.Length--; /* Subtract one for null terminator */
667 /* CurrentPath is the path to this scope (where we are in the namespace) */
669 CurrentPath.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
670 Status = AcpiNsHandleToPathname (CurrentNode, &CurrentPath);
671 if (ACPI_FAILURE (Status))
673 AslCoreSubsystemError (Op, Status, "Getting Current NamePath",
677 CurrentPath.Length--; /* Subtract one for null terminator */
679 /* Debug output only */
681 Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, AmlNameString,
682 NULL, &ExternalNameString);
683 if (ACPI_FAILURE (Status))
685 AslCoreSubsystemError (Op, Status, "Externalizing NamePath",
690 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
691 "CURRENT SCOPE: (%2u) %-37s FULL PATH TO NAME: (%2u) %-32s ACTUAL AML:%-32s\n",
692 (UINT32) CurrentPath.Length, (char *) CurrentPath.Pointer,
693 (UINT32) TargetPath.Length, (char *) TargetPath.Pointer,
694 ExternalNameString));
696 ACPI_FREE (ExternalNameString);
699 * Attempt an optmization depending on the type of namepath
701 if (Flags & (AML_NAMED | AML_CREATE))
704 * This is a named opcode and the namepath is a name declaration, not
707 Status = OptOptimizeNameDeclaration (Op, WalkState, CurrentNode,
708 TargetNode, AmlNameString, &NewPath);
709 if (ACPI_FAILURE (Status))
713 * optimize the namestring with carats (up-arrow)
715 Status = OptBuildShortestPath (Op, WalkState, CurrentNode,
716 TargetNode, &CurrentPath, &TargetPath,
717 AmlNameStringLength, 1, &NewPath);
723 * This is a reference to an existing named object
725 * 1) Check if search-to-root can be utilized using the last
726 * NameSeg of the NamePath
728 Status = OptSearchToRoot (Op, WalkState, CurrentNode,
729 TargetNode, &TargetPath, &NewPath);
730 if (ACPI_FAILURE (Status))
733 * 2) Search-to-root could not be used, now attempt to
734 * optimize the namestring with carats (up-arrow)
736 Status = OptBuildShortestPath (Op, WalkState, CurrentNode,
737 TargetNode, &CurrentPath, &TargetPath,
738 AmlNameStringLength, 0, &NewPath);
743 * Success from above indicates that the NamePath was successfully
744 * optimized. We need to update the parse op with the new name
746 if (ACPI_SUCCESS (Status))
748 HowMuchShorter = (AmlNameStringLength - strlen (NewPath));
749 OptTotal += HowMuchShorter;
751 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
752 " REDUCED BY %2u (TOTAL SAVED %2u)",
753 (UINT32) HowMuchShorter, OptTotal));
755 if (Flags & AML_NAMED)
757 if (Op->Asl.AmlOpcode == AML_ALIAS_OP)
760 * ALIAS is the only oddball opcode, the name declaration
761 * (alias name) is the second operand
763 Op->Asl.Child->Asl.Next->Asl.Value.String = NewPath;
764 Op->Asl.Child->Asl.Next->Asl.AmlLength = strlen (NewPath);
768 Op->Asl.Child->Asl.Value.String = NewPath;
769 Op->Asl.Child->Asl.AmlLength = strlen (NewPath);
772 else if (Flags & AML_CREATE)
774 /* Name must appear as the last parameter */
776 NextOp = Op->Asl.Child;
777 while (!(NextOp->Asl.CompileFlags & NODE_IS_NAME_DECLARATION))
779 NextOp = NextOp->Asl.Next;
781 /* Update the parse node with the new NamePath */
783 NextOp->Asl.Value.String = NewPath;
784 NextOp->Asl.AmlLength = strlen (NewPath);
788 /* Update the parse node with the new NamePath */
790 Op->Asl.Value.String = NewPath;
791 Op->Asl.AmlLength = strlen (NewPath);
796 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " ALREADY OPTIMAL"));
799 /* Cleanup path buffers */
801 ACPI_FREE (TargetPath.Pointer);
802 ACPI_FREE (CurrentPath.Pointer);
804 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "\n"));