OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [tm/] [pr47530.C] - Blame information for rev 774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 693 jeremybenn
// { dg-do compile }
2
// { dg-options "-fgnu-tm -O2 -fdump-tree-optimized" }
3
 
4
typedef __SIZE_TYPE__ size_t;
5
extern void *malloc(size_t);
6
 
7
namespace bench
8
{
9
    class LLNode
10
    {
11
        LLNode* next;
12
        int data;
13
 
14
    public:
15
        __attribute__((transaction_safe))
16
        LLNode(int val, LLNode* m_next)
17
        {
18
                data = val;
19
                next = m_next;
20
        }
21
        __attribute__((transaction_safe))
22
          ~LLNode(){}
23
        __attribute__((transaction_safe))
24
          int get_val()  {return data;}
25
        __attribute__((transaction_safe))
26
          LLNode* get_next()  {return next;}
27
        __attribute__((transaction_safe))
28
          void set_val(int val) {data = val;}
29
        __attribute__((transaction_safe))
30
          void set_next(LLNode* n)  {next = n;}
31
        __attribute__((transaction_safe))
32
          void *operator new(size_t size);
33
    };
34
 
35
    class LinkedList
36
    {
37
      LLNode* head;
38
    public:
39
        LinkedList();
40
        void insert(int val);
41
    };
42
}
43
 
44
using bench::LinkedList;
45
using bench::LLNode;
46
 
47
 
48
__attribute__((transaction_safe))
49
void* LLNode::operator new(size_t size)
50
{
51
  return malloc(size);
52
}
53
 
54
LinkedList::LinkedList() : head(new LLNode(-1, 0)) { }
55
 
56
void LinkedList::insert(int val)
57
{
58
  __transaction_atomic {
59
    LLNode* prev = head;
60
    LLNode* curr = head->get_next();
61
 
62
    while (curr != 0) {
63
      if (curr->get_val() >= val)
64
        break;
65
      prev = curr;
66
      curr = prev->get_next();
67
    }
68
 
69
    if (!curr || (curr->get_val() > val)){
70
      LLNode* tmp = new LLNode(val,curr);
71
      prev->set_next(tmp);
72
    }
73
  }
74
}
75
 
76
// Make sure we don't do tail optimization on the commit.
77
// { dg-final { scan-tree-dump-times "commitTransaction...; .tail call" 0 "optimized" } }
78
// { dg-final { cleanup-tree-dump "optimized" } }
79
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.