Opened 4 years ago

Closed 2 years ago

#5233 closed feature request (fixed)

Support specifying the assembly that should be generated

Reported by: tibbe Owned by: simonmar
Priority: normal Milestone: 7.8.1
Component: Test Suite Version: 7.0.3
Keywords: Cc: johan.tibell@…, ikke+ghc@…, axman6@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description

We want to make sure that native code generator optimizations, like primop unrolling, always fire. We can do this by allowing the programmer to specify what assembly should be generated for a particular snippet of Cmm. The programmer gives a snippet of Cmm:

#include "Cmm.h"

// Large memcpy's should lower to calls.
callMemcpy
{
  W_ dst, src;
  prim %memcpy(dst "ptr", src "ptr", 1024, 4) [];
}

and the expected assembly output:

callMemcpy:
movq  ; Move arguments into place
movq
movl
movl
call memcpy

The expected output shouldn't mention specific register names as these are likely to change.

Attachments (1)

0001-Make-it-possible-to-test-the-generated-assembly.patch (4.5 KB) - added by tibbe 4 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 Changed 4 years ago by tibbe

  • Cc johan.tibell@… added
  • Status changed from new to patch

I've attached a patch that implements this behavior, together with a first test case.

comment:2 Changed 4 years ago by igloo

  • Milestone set to 7.2.1

comment:3 Changed 4 years ago by tibbe

  • Owner set to simonmar

comment:4 Changed 3 years ago by igloo

  • Milestone changed from 7.2.1 to 7.4.1

comment:5 Changed 3 years ago by igloo

  • Milestone changed from 7.4.1 to 7.6.1

comment:6 Changed 3 years ago by nicolast

  • Cc ikke+ghc@… added

This looks somewhat like LLVM's "FileCheck" system [1]. Might be useful?

Next to that: maybe removing all register names from the asm to be generated could be replaced by using placeholders (like "Variables" in FileCheck).

[1] http://llvm.org/docs/TestingGuide.html#FileCheck

comment:7 Changed 3 years ago by Axman6

  • Cc axman6@… added

comment:8 Changed 3 years ago by igloo

  • Milestone changed from 7.6.1 to 7.6.2

comment:9 Changed 2 years ago by simonmar

  • difficulty set to Unknown
  • Milestone changed from 7.6.2 to 7.8.1
  • Resolution set to fixed
  • Status changed from patch to closed

Committed, thanks:

commit a351a67a242f8484764fe450b973b2d4ac9d098e
Author: Johan Tibell <[email protected]>
Date:   Tue May 31 11:56:58 2011 +0200

    Make it possible to test the generated assembly
    
    This test framework feature is inspired by a similar feature in LLVM.
    The programmer writes a bit of Cmm
    
        #include "Cmm.h"
    
        // Large memcpy's should lower to calls.
        callMemcpy
        {
          W_ dst, src;
          prim %memcpy(dst "ptr", src "ptr", 1024, 4) [];
        }
    
    and asserts what the generated assembly should look like, modulo
    register naming.
    
        callMemcpy:
        movq  ; Move arguments into place
        movq
        movl
        movl
        call memcpy
    
    Patch edited and updated by Simon Marlow, and I also added a test for
    unrolling memcpy and a simple constant-propagation test.
Note: See TracTickets for help on using tickets.