llvm.org GIT mirror llvm / 48abc5c
Corrected many typing errors. And removed 'nest' parameter handling for fastcc from X86CallingConv.td. This means that nested functions are not supported for calling convention 'fastcc'. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42934 91177308-0d34-0410-b5e6-96231b3b80d8 Arnold Schwaighofer 13 years ago
12 changed file(s) with 50 addition(s) and 49 deletion(s). Raw diff Collapse all Expand all
860860 virtual SDOperand LowerOperation(SDOperand Op, SelectionDAG &DAG);
861861
862862 /// IsEligibleForTailCallOptimization - Check whether the call is eligible for
863 /// tail call optimization. Target which want to do tail call optimization
864 /// should implement this function.
863 /// tail call optimization. Targets which want to do tail call optimization
864 /// should override this function.
865865 virtual bool IsEligibleForTailCallOptimization(SDOperand Call,
866866 SDOperand Ret,
867867 SelectionDAG &DAG) const {
7373 /// be emitted.
7474 extern bool ExceptionHandling;
7575
76 /// PerformTailCallOpt - This flag is enabled when the -tailcallopt is
77 /// specified on the commandline. When the flag is on, the target will perform
78 /// tail call optimization (pop the caller's stack) providing it supports it.
76 /// PerformTailCallOpt - This flag is enabled when -tailcallopt is specified
77 /// on the commandline. When the flag is on, the target will perform tail call
78 /// optimization (pop the caller's stack) providing it supports it.
7979 extern bool PerformTailCallOpt;
8080 } // End llvm namespace
8181
44754475 }
44764476
44774477 /// CheckDAGForTailCallsAndFixThem - This Function looks for CALL nodes in the
4478 /// DAG and fixes their tailcall attribute operand
4478 /// DAG and fixes their tailcall attribute operand.
44794479 static void CheckDAGForTailCallsAndFixThem(SelectionDAG &DAG,
44804480 TargetLowering& TLI) {
44814481 SDNode * Ret = NULL;
44964496 cast(OpCall.getOperand(3))->getValue() != 0;
44974497 // If CALL node has tail call attribute set to true and the call is not
44984498 // eligible (no RET or the target rejects) the attribute is fixed to
4499 // false. The TargetLowering::IsEligibleForTailCallOptimization function
4499 // false. The TargetLowering::IsEligibleForTailCallOptimization function
45004500 // must correctly identify tail call optimizable calls.
45014501 if (isMarkedTailCall &&
45024502 (Ret==NULL ||
13511351 L5:
13521352
13531353 //===---------------------------------------------------------------------===//
1354
13541355 Tail call optimization improvements: Tail call optimization currently
1355 pushes all arguments on the top of the stack (their normal place if
1356 that was a not tail call optimized functiong call ) before moving them
1357 to actual stack slot. this is done to prevent overwriting of paramters
1358 (see example below) that might be used, since the arguments of the
1359 callee overwrites callers arguments.
1360
1361 example:
1356 pushes all arguments on the top of the stack (their normal place for
1357 non-tail call optimized calls) before moving them to actual stack
1358 slot. This is done to prevent overwriting of parameters (see example
1359 below) that might be used, since the arguments of the callee
1360 overwrites caller's arguments.
1361
1362 example:
13621363
13631364 int callee(int32, int64);
13641365 int caller(int32 arg1, int32 arg2) {
13701371 [arg2] -> [(int64)
13711372 [RETADDR] local ]
13721373
1373 moving arg1 onto the stack slot of callee function would overwrite
1374 Moving arg1 onto the stack slot of callee function would overwrite
13741375 arg2 of the caller.
13751376
13761377 Possible optimizations:
13771378
1378 - only push those arguments to the top of the stack that are actual
1379 - Only push those arguments to the top of the stack that are actual
13791380 parameters of the caller function and have no local value in the
1380 caller
1381
1382 in above example local does not need to be pushed onto the top of
1383 the stack as it is definitetly not a caller's function parameter
1384
1385 - analyse the actual parameters of the callee to see which would
1386 overwrite a caller paramter which is used by the callee and only
1387 push them onto the top of the stack
1381 caller.
1382
1383 In the above example local does not need to be pushed onto the top
1384 of the stack as it is definitely not a caller's function
1385 parameter.
1386
1387 - Analyse the actual parameters of the callee to see which would
1388 overwrite a caller parameter which is used by the callee and only
1389 push them onto the top of the stack.
13881390
13891391 int callee (int32 arg1, int32 arg2);
13901392 int caller (int32 arg1, int32 arg2) {
13911393 return callee(arg1,arg2);
13921394 }
13931395
1394 here we don't need to write any variables to the top of the stack
1395 since they don't overwrite each other
1396 Here we don't need to write any variables to the top of the stack
1397 since they don't overwrite each other.
13961398
13971399 int callee (int32 arg1, int32 arg2);
13981400 int caller (int32 arg1, int32 arg2) {
13991401 return callee(arg2,arg1);
14001402 }
14011403
1402 here we need to push the arguments because they overwrite each other
1403
1404
1405 code for lowering directly onto callers arguments:
1404 Here we need to push the arguments because they overwrite each
1405 other.
1406
1407
1408 Code for lowering directly onto callers arguments:
14061409 + SmallVector, 8> RegsToPass;
14071410 + SmallVector MemOpChains;
14081411 +
None //===- X86.td - Target definition file for the Intel X86 arch ---*- C++ -*-===//
0 //===- X86.td - Target definition file for the Intel X86 ---*- tablegen -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
None //===- X86CallingConv.td - Calling Conventions for X86 32/64 ----*- C++ -*-===//
0 //===- X86CallingConv.td - Calling Conventions X86 32/64 ---*- tablegen -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
126126 CCIfType<[v8i8, v4i16, v2i32, v1i64], CCAssignToStack<8, 8>>
127127 ]>;
128128
129 // tail call convetion (fast) one register is reserved for target address
129 // Tail call convention (fast): One register is reserved for target address,
130130 // namely R9
131131 def CC_X86_64_TailCall : CallingConv<[
132132 // Promote i8/i16 arguments to i32.
206206 CCDelegateTo
207207 ]>;
208208
209 /// Same as C calling convention up to nonfree ECX which is used for storing
210 /// potential pointer to tail called function
209 /// Same as C calling convention except for non-free ECX which is used for storing
210 /// a potential pointer to the tail called function.
211211 def CC_X86_32_TailCall : CallingConv<[
212212 // Promote i8/i16 arguments to i32.
213213 CCIfType<[i8, i16], CCPromoteToType>,
214214
215 // The 'nest' parameter, if any, is passed in ECX.
216 CCIfNest>,
217
215 // Nested functions are currently not supported by fastcc.
216
218217 // The first 3 integer arguments, if marked 'inreg' and if the call is not
219218 // a vararg call, are passed in integer registers.
220219 CCIfNotVarArg>>>,
None //===-- X86ISelLowering.cpp - X86 DAG Lowering Implementation -------------===//
0 //===-- X86isellowering.cpp - X86 DAG Lowering Implementation -------------===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
14011401 // * elf/pic is disabled OR
14021402 // * elf/pic enabled + callee is in module + callee has
14031403 // visibility protected or hidden
1404 // To ensure the stack is aligned according to platform abi pass
1405 // tail-call-align-stack. This makes sure that argument delta is always
1406 // multiples of stack alignment. (Dynamic linkers need this - darwin's dyld for
1407 // example)
1404 // To keep the stack aligned according to platform abi the function
1405 // GetAlignedArgumentStackSize ensures that argument delta is always multiples
1406 // of stack alignment. (Dynamic linkers need this - darwin's dyld for example)
14081407 // If a tail called function callee has more arguments than the caller the
14091408 // caller needs to make sure that there is room to move the RETADDR to. This is
1410 // achived by reserving an area the size of the argument delta right after the
1409 // achieved by reserving an area the size of the argument delta right after the
14111410 // original REtADDR, but before the saved framepointer or the spilled registers
14121411 // e.g. caller(arg1, arg2) calls callee(arg1, arg2,arg3,arg4)
14131412 // stack layout:
None //==- X86InstrFPStack.td - Describe the X86 Instruction Set -------*- C++ -*-=//
0 //==- X86InstrFPStack.td - Describe the X86 Instruction Set --*- tablegen -*-=//
11 //
22 // The LLVM Compiler Infrastructure
33 //
None //===- X86InstrInfo.td - Describe the X86 Instruction Set -------*- C++ -*-===//
0 //===- X86InstrInfo.td - Describe the X86 Instruction Set --*- tablegen -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
None //====- X86InstrSSE.td - Describe the X86 Instruction Set -------*- C++ -*-===//
0 //====- X86InstrSSE.td - Describe the X86 Instruction Set --*- tablegen -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
None //====- X86InstrX86-64.td - Describe the X86 Instruction Set ----*- C++ -*-===//
0 //====- X86InstrX86-64.td - Describe the X86 Instr. Set ----*- tablegen -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
None //===- X86RegisterInfo.td - Describe the X86 Register File ------*- C++ -*-===//
0 //===- X86RegisterInfo.td - Describe the X86 Register File --*- tablegen -*-==//
11 //
22 // The LLVM Compiler Infrastructure
33 //