瀏覽代碼

+ added "cleanup" landing pad opcode

git-svn-id: branches/debug_eh@40411 -
Jonas Maebe 6 年之前
父節點
當前提交
ce7579bd50
共有 4 個文件被更改,包括 17 次插入3 次删除
  1. 12 1
      compiler/llvm/aasmllvm.pas
  2. 3 2
      compiler/llvm/agllvm.pas
  3. 1 0
      compiler/llvm/itllvm.pas
  4. 1 0
      compiler/llvm/llvmbase.pas

+ 12 - 1
compiler/llvm/aasmllvm.pas

@@ -110,6 +110,7 @@ interface
         constructor blockaddress(fun, lab: tasmsymbol);
         constructor blockaddress(fun, lab: tasmsymbol);
         constructor landingpad(dst:tregister;def:tdef;firstclause:taillvm);
         constructor landingpad(dst:tregister;def:tdef;firstclause:taillvm);
         constructor exceptclause(op:tllvmop;def:tdef;kind:TAsmSymbol;nextclause:taillvm);
         constructor exceptclause(op:tllvmop;def:tdef;kind:TAsmSymbol;nextclause:taillvm);
+        constructor cleanupclause;
 
 
         { e.g. dst = call retsize name (paras) }
         { e.g. dst = call retsize name (paras) }
         constructor call_size_name_paras(callpd: tdef; dst: tregister;retsize: tdef;name:tasmsymbol;paras: tfplist);
         constructor call_size_name_paras(callpd: tdef; dst: tregister;retsize: tdef;name:tasmsymbol;paras: tfplist);
@@ -486,7 +487,10 @@ uses
       begin
       begin
         if llvmopcode<>la_landingpad then
         if llvmopcode<>la_landingpad then
           internalerror(2018052001);
           internalerror(2018052001);
-        clause:=taillvm.exceptclause(op,voidpointertype,nil,nil);
+        if op<>la_cleanup then
+          clause:=taillvm.exceptclause(op,voidpointertype,nil,nil)
+        else
+          clause:=taillvm.cleanupclause;
         lastclause:=self;
         lastclause:=self;
         while assigned(lastclause.oper[2]^.ai) do
         while assigned(lastclause.oper[2]^.ai) do
           lastclause:=taillvm(lastclause.oper[2]^.ai);
           lastclause:=taillvm(lastclause.oper[2]^.ai);
@@ -1090,6 +1094,13 @@ uses
       end;
       end;
 
 
 
 
+    constructor taillvm.cleanupclause;
+      begin
+        create_llvm(la_cleanup);
+        ops:=0;
+      end;
+
+
     constructor taillvm.call_size_name_paras(callpd: tdef; dst: tregister; retsize: tdef; name:tasmsymbol; paras: tfplist);
     constructor taillvm.call_size_name_paras(callpd: tdef; dst: tregister; retsize: tdef; name:tasmsymbol; paras: tfplist);
       begin
       begin
         create_llvm(la_call);
         create_llvm(la_call);

+ 3 - 2
compiler/llvm/agllvm.pas

@@ -577,7 +577,8 @@ implementation
         la_cmpxchg,
         la_cmpxchg,
         la_atomicrmw,
         la_atomicrmw,
         la_catch,
         la_catch,
-        la_filter:
+        la_filter,
+        la_cleanup:
           begin
           begin
             { instructions that never have a result }
             { instructions that never have a result }
           end;
           end;
@@ -694,7 +695,7 @@ implementation
 
 
                    owner.writer.AsmWrite(getopstr(taillvm(hp).oper[i]^,op in [la_load,la_store]));
                    owner.writer.AsmWrite(getopstr(taillvm(hp).oper[i]^,op in [la_load,la_store]));
                    if (taillvm(hp).oper[i]^.typ in [top_def,top_cond,top_fpcond]) or
                    if (taillvm(hp).oper[i]^.typ in [top_def,top_cond,top_fpcond]) or
-                      (op in [la_call,la_invoke,la_landingpad,la_catch,la_filter]) then
+                      (op in [la_call,la_invoke,la_landingpad,la_catch,la_filter,la_cleanup]) then
                      sep :=' '
                      sep :=' '
                    else
                    else
                      sep:=', ';
                      sep:=', ';

+ 1 - 0
compiler/llvm/itllvm.pas

@@ -62,6 +62,7 @@ interface
         'type', { type definition }
         'type', { type definition }
         'catch', { catch exception }
         'catch', { catch exception }
         'filter', { exception filter }
         'filter', { exception filter }
+        'cleanup', { exception cleanup/finally }
         'invalid1', { la_x_to_inttoptr }
         'invalid1', { la_x_to_inttoptr }
         'invalid2', { la_ptrtoint_to_x }
         'invalid2', { la_ptrtoint_to_x }
         'asm' { la_asmblock }
         'asm' { la_asmblock }

+ 1 - 0
compiler/llvm/llvmbase.pas

@@ -70,6 +70,7 @@ interface
       la_type, { type definition }
       la_type, { type definition }
       la_catch, { catch clause of a landingpad }
       la_catch, { catch clause of a landingpad }
       la_filter, { filter clause of a landingpad }
       la_filter, { filter clause of a landingpad }
+      la_cleanup, { cleanup clause of a landingpad (finally) }
       la_x_to_inttoptr, { have to convert something first to int before it can be converted to a pointer }
       la_x_to_inttoptr, { have to convert something first to int before it can be converted to a pointer }
       la_ptrtoint_to_x, { have to convert a pointer first to int before it can be converted to something else }
       la_ptrtoint_to_x, { have to convert a pointer first to int before it can be converted to something else }
       la_asmblock
       la_asmblock