1 /******************************************************************************
3 * Module Name: aslopt- Compiler optimizations
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2017, 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)[
136 TargetPath->Length - ACPI_NAME_SIZE]);
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,
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;
220 char *NewPathInternal;
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 Index = (NumCommonSegments * ACPI_PATH_SEGMENT_LENGTH) + 1;
258 if (!ACPI_COMPARE_NAME (
259 &(ACPI_CAST_PTR (char, TargetPath->Pointer)) [Index],
260 &(ACPI_CAST_PTR (char, CurrentPath->Pointer)) [Index]))
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
301 ACPI_ALLOCATE_ZEROED (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 &&
319 (CurrentPath->Length > TargetPath->Length))
322 * The current path is longer than the target, and the target is a
323 * subpath of the current path. We must include one more NameSeg of
326 Index -= ACPI_PATH_SEGMENT_LENGTH;
328 /* Special handling for Scope() operator */
330 if (Op->Asl.AmlOpcode == AML_SCOPE_OP)
332 NewPathExternal[i] = AML_PARENT_PREFIX;
334 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "(EXTRA ^)"));
338 /* Make sure we haven't gone off the end of the target path */
340 if (Index > TargetPath->Length)
342 Index = TargetPath->Length;
345 strcpy (&NewPathExternal[i],
346 &(ACPI_CAST_PTR (char, TargetPath->Pointer))[Index]);
347 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " %-24s", NewPathExternal));
350 * Internalize the new target string and check it against the original
351 * string to make sure that this is in fact an optimization. If the
352 * original string is already optimal, there is no point in continuing.
354 Status = AcpiNsInternalizeName (NewPathExternal, &NewPathInternal);
355 if (ACPI_FAILURE (Status))
357 AslCoreSubsystemError (Op, Status, "Internalizing new NamePath",
362 if (strlen (NewPathInternal) >= AmlNameStringLength)
364 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
365 " NOT SHORTER (New %u old %u)",
366 (UINT32) strlen (NewPathInternal),
367 (UINT32) AmlNameStringLength));
369 ACPI_FREE (NewPathInternal);
370 Status = AE_NOT_FOUND;
375 * Check to make sure that the optimization finds the node we are
376 * looking for. This is simply a sanity check on the new
377 * path that has been created.
379 Status = AcpiNsLookup (&ScopeInfo, NewPathInternal,
380 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
381 ACPI_NS_DONT_OPEN_SCOPE, WalkState, &(Node));
382 if (ACPI_SUCCESS (Status))
384 /* Found the namepath, but make sure the node is correct */
386 if (Node == TargetNode)
388 /* The lookup matched the node, accept this optimization */
390 AslError (ASL_OPTIMIZATION, ASL_MSG_NAME_OPTIMIZATION,
391 Op, NewPathExternal);
392 *ReturnNewPath = NewPathInternal;
396 /* Node is not correct, do not use this optimization */
398 Status = AE_NOT_FOUND;
399 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " ***** WRONG NODE"));
400 AslError (ASL_WARNING, ASL_MSG_COMPILER_INTERNAL, Op,
401 "Not using optimized name - found wrong node");
406 /* The lookup failed, we obviously cannot use this optimization */
408 ACPI_FREE (NewPathInternal);
410 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " ***** NOT FOUND"));
411 AslError (ASL_WARNING, ASL_MSG_COMPILER_INTERNAL, Op,
412 "Not using optimized name - did not find node");
417 ACPI_FREE (NewPathExternal);
422 /*******************************************************************************
424 * FUNCTION: OptOptimizeNameDeclaration
426 * PARAMETERS: Op - Current parser op
427 * WalkState - Current state
428 * CurrentNode - Where we are in the namespace
429 * AmlNameString - Unoptimized namepath
430 * NewPath - Where the optimized path is returned
432 * RETURN: Status. AE_OK If path is optimized
434 * DESCRIPTION: Perform a simple optimization of removing an extraneous
435 * backslash prefix if we are already at the root scope.
437 ******************************************************************************/
440 OptOptimizeNameDeclaration (
441 ACPI_PARSE_OBJECT *Op,
442 ACPI_WALK_STATE *WalkState,
443 ACPI_NAMESPACE_NODE *CurrentNode,
444 ACPI_NAMESPACE_NODE *TargetNode,
449 char *NewPathExternal;
450 ACPI_NAMESPACE_NODE *Node;
453 ACPI_FUNCTION_TRACE (OptOptimizeNameDeclaration);
456 if (((CurrentNode == AcpiGbl_RootNode) ||
457 (Op->Common.Parent->Asl.ParseOpcode == PARSEOP_DEFINITION_BLOCK)) &&
458 (ACPI_IS_ROOT_PREFIX (AmlNameString[0])))
461 * The current scope is the root, and the namepath has a root prefix
462 * that is therefore extraneous. Remove it.
464 *NewPath = &AmlNameString[1];
468 Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, *NewPath,
469 NULL, &NewPathExternal);
470 if (ACPI_FAILURE (Status))
472 AslCoreSubsystemError (Op, Status, "Externalizing NamePath",
478 * Check to make sure that the optimization finds the node we are
479 * looking for. This is simply a sanity check on the new
480 * path that has been created.
482 * We know that we are at the root, so NULL is used for the scope.
484 Status = AcpiNsLookup (NULL, *NewPath,
485 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
486 ACPI_NS_DONT_OPEN_SCOPE, WalkState, &(Node));
487 if (ACPI_SUCCESS (Status))
489 /* Found the namepath, but make sure the node is correct */
491 if (Node == TargetNode)
493 /* The lookup matched the node, accept this optimization */
495 AslError (ASL_OPTIMIZATION, ASL_MSG_NAME_OPTIMIZATION,
496 Op, NewPathExternal);
498 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
499 "AT ROOT: %-24s", NewPathExternal));
503 /* Node is not correct, do not use this optimization */
505 Status = AE_NOT_FOUND;
506 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
507 " ***** WRONG NODE"));
508 AslError (ASL_WARNING, ASL_MSG_COMPILER_INTERNAL, Op,
509 "Not using optimized name - found wrong node");
514 /* The lookup failed, we obviously cannot use this optimization */
516 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
517 " ***** NOT FOUND"));
518 AslError (ASL_WARNING, ASL_MSG_COMPILER_INTERNAL, Op,
519 "Not using optimized name - did not find node");
522 ACPI_FREE (NewPathExternal);
526 /* Could not optimize */
528 return (AE_NOT_FOUND);
532 /*******************************************************************************
534 * FUNCTION: OptOptimizeNamePath
536 * PARAMETERS: Op - Current parser op
537 * Flags - Opcode info flags
538 * WalkState - Current state
539 * AmlNameString - Unoptimized namepath
540 * TargetNode - Node to which AmlNameString refers
542 * RETURN: None. If path is optimized, the Op is updated with new path
544 * DESCRIPTION: Optimize a Named Declaration or Reference to the minimal length.
545 * Must take into account both the current location in the
546 * namespace and the actual reference path.
548 ******************************************************************************/
551 OptOptimizeNamePath (
552 ACPI_PARSE_OBJECT *Op,
554 ACPI_WALK_STATE *WalkState,
556 ACPI_NAMESPACE_NODE *TargetNode)
559 ACPI_BUFFER TargetPath;
560 ACPI_BUFFER CurrentPath;
561 ACPI_SIZE AmlNameStringLength;
562 ACPI_NAMESPACE_NODE *CurrentNode;
563 char *ExternalNameString;
564 char *NewPath = NULL;
565 ACPI_SIZE HowMuchShorter;
566 ACPI_PARSE_OBJECT *NextOp;
569 ACPI_FUNCTION_TRACE (OptOptimizeNamePath);
572 /* This is an optional optimization */
574 if (!Gbl_ReferenceOptimizationFlag)
579 /* Various required items */
581 if (!TargetNode || !WalkState || !AmlNameString || !Op->Common.Parent)
586 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
587 "PATH OPTIMIZE: Line %5d ParentOp [%12.12s] ThisOp [%12.12s] ",
588 Op->Asl.LogicalLineNumber,
589 AcpiPsGetOpcodeName (Op->Common.Parent->Common.AmlOpcode),
590 AcpiPsGetOpcodeName (Op->Common.AmlOpcode)));
592 if (!(Flags & (AML_NAMED | AML_CREATE)))
594 if (Op->Asl.CompileFlags & NODE_IS_NAME_DECLARATION)
596 /* We don't want to fuss with actual name declaration nodes here */
598 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
599 "******* NAME DECLARATION\n"));
605 * The original path must be longer than one NameSeg (4 chars) for there
606 * to be any possibility that it can be optimized to a shorter string
608 AmlNameStringLength = strlen (AmlNameString);
609 if (AmlNameStringLength <= ACPI_NAME_SIZE)
611 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
612 "NAMESEG %4.4s\n", AmlNameString));
617 * We need to obtain the node that represents the current scope -- where
618 * we are right now in the namespace. We will compare this path
619 * against the Namepath, looking for commonality.
621 CurrentNode = AcpiGbl_RootNode;
622 if (WalkState->ScopeInfo)
624 CurrentNode = WalkState->ScopeInfo->Scope.Node;
627 if (Flags & (AML_NAMED | AML_CREATE))
629 /* This is the declaration of a new name */
631 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "NAME\n"));
634 * The node of interest is the parent of this node (the containing
635 * scope). The actual namespace node may be up more than one level
636 * of parse op or it may not exist at all (if we traverse back
639 NextOp = Op->Asl.Parent;
640 while (NextOp && (!NextOp->Asl.Node))
642 NextOp = NextOp->Asl.Parent;
645 if (NextOp && NextOp->Asl.Node)
647 CurrentNode = NextOp->Asl.Node;
651 CurrentNode = AcpiGbl_RootNode;
656 /* This is a reference to an existing named object */
658 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "REFERENCE\n"));
662 * Obtain the full paths to the two nodes that we are interested in
663 * (Target and current namespace location) in external
664 * format -- something we can easily manipulate
666 TargetPath.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
667 Status = AcpiNsHandleToPathname (TargetNode, &TargetPath, FALSE);
668 if (ACPI_FAILURE (Status))
670 AslCoreSubsystemError (Op, Status, "Getting Target NamePath",
675 TargetPath.Length--; /* Subtract one for null terminator */
677 /* CurrentPath is the path to this scope (where we are in the namespace) */
679 CurrentPath.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
680 Status = AcpiNsHandleToPathname (CurrentNode, &CurrentPath, FALSE);
681 if (ACPI_FAILURE (Status))
683 AslCoreSubsystemError (Op, Status, "Getting Current NamePath",
688 CurrentPath.Length--; /* Subtract one for null terminator */
690 /* Debug output only */
692 Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, AmlNameString,
693 NULL, &ExternalNameString);
694 if (ACPI_FAILURE (Status))
696 AslCoreSubsystemError (Op, Status, "Externalizing NamePath",
701 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
702 "CURRENT SCOPE: (%2u) %-37s FULL PATH TO NAME: (%2u) %-32s ACTUAL AML:%-32s\n",
703 (UINT32) CurrentPath.Length, (char *) CurrentPath.Pointer,
704 (UINT32) TargetPath.Length, (char *) TargetPath.Pointer,
705 ExternalNameString));
707 ACPI_FREE (ExternalNameString);
710 * Attempt an optmization depending on the type of namepath
712 if (Flags & (AML_NAMED | AML_CREATE))
715 * This is a named opcode and the namepath is a name declaration, not
718 Status = OptOptimizeNameDeclaration (Op, WalkState, CurrentNode,
719 TargetNode, AmlNameString, &NewPath);
720 if (ACPI_FAILURE (Status))
724 * optimize the namestring with carats (up-arrow)
726 Status = OptBuildShortestPath (Op, WalkState, CurrentNode,
727 TargetNode, &CurrentPath, &TargetPath,
728 AmlNameStringLength, 1, &NewPath);
734 * This is a reference to an existing named object
736 * 1) Check if search-to-root can be utilized using the last
737 * NameSeg of the NamePath
739 Status = OptSearchToRoot (Op, WalkState, CurrentNode,
740 TargetNode, &TargetPath, &NewPath);
741 if (ACPI_FAILURE (Status))
744 * 2) Search-to-root could not be used, now attempt to
745 * optimize the namestring with carats (up-arrow)
747 Status = OptBuildShortestPath (Op, WalkState, CurrentNode,
748 TargetNode, &CurrentPath, &TargetPath,
749 AmlNameStringLength, 0, &NewPath);
754 * Success from above indicates that the NamePath was successfully
755 * optimized. We need to update the parse op with the new name
757 if (ACPI_SUCCESS (Status))
759 HowMuchShorter = (AmlNameStringLength - strlen (NewPath));
760 OptTotal += HowMuchShorter;
762 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
763 " REDUCED BY %2u (TOTAL SAVED %2u)",
764 (UINT32) HowMuchShorter, OptTotal));
766 if (Flags & AML_NAMED)
768 if (Op->Asl.AmlOpcode == AML_ALIAS_OP)
771 * ALIAS is the only oddball opcode, the name declaration
772 * (alias name) is the second operand
774 Op->Asl.Child->Asl.Next->Asl.Value.String = NewPath;
775 Op->Asl.Child->Asl.Next->Asl.AmlLength = strlen (NewPath);
779 Op->Asl.Child->Asl.Value.String = NewPath;
780 Op->Asl.Child->Asl.AmlLength = strlen (NewPath);
783 else if (Flags & AML_CREATE)
785 /* Name must appear as the last parameter */
787 NextOp = Op->Asl.Child;
788 while (!(NextOp->Asl.CompileFlags & NODE_IS_NAME_DECLARATION))
790 NextOp = NextOp->Asl.Next;
792 /* Update the parse node with the new NamePath */
794 NextOp->Asl.Value.String = NewPath;
795 NextOp->Asl.AmlLength = strlen (NewPath);
799 /* Update the parse node with the new NamePath */
801 Op->Asl.Value.String = NewPath;
802 Op->Asl.AmlLength = strlen (NewPath);
807 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " ALREADY OPTIMAL"));
810 /* Cleanup path buffers */
812 ACPI_FREE (TargetPath.Pointer);
813 ACPI_FREE (CurrentPath.Pointer);
815 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "\n"));